码迷,mamicode.com
首页 > 其他好文 > 详细

使用正则表达式,取得点击次数,函数抽离

时间:2018-04-09 13:08:28      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:clip   api   can   函数   正则表达式   sel   search   iss   hat   

import re

a = "123456789@qq.com"
b = 020-88770099
mail = re.search(\d{6,12}@[a-zA-Z0-9]+.[a-zA-Z0-9]+, a).group(0)
tele_num = re.search(\d{3,4}-\d{6,8}, b).group(0)
print(mail+\n+tele_num)
import re


new = ‘‘‘I‘ve been reading books of old
The legends and the myths
Achilles and his gold
Hercules and his gifts
Spiderman‘s control
And Batman with his fists

And clearly I don‘t see myself upon that list
She said where‘d you wanna go
How much you wanna risk
I‘m not looking for somebody
With some Superhuman gifts
Some Superhero

Some fairytale bliss
Just something I can turn to
Somebody I can kiss
I want something just like this
Doo doo doo doo doo doo

Doo doo doo doo doo

Doo doo doo doo doo doo
Oh I want something just like this
Doo doo doo doo doo doo

Doo doo doo doo doo

Doo doo doo doo doo doo
Oh I want something just like this

I want something just like this

I‘ve been reading books of old

The legends and the myths
The testaments they told
The moon and its eclipse
And Superman unrolls
A suit before he lifts

But I‘m not the kind of person that it fits
She said where‘d you wanna go
How much you wanna risk
I‘m not looking for somebody
With some Superhuman gifts
Some Superhero

Some fairytale bliss
Just something I can turn to
Somebody I can miss
I want something just like this

I want something just like this

Oh I want something just like this
Doo doo doo doo doo doo

Doo doo doo doo doo

Doo doo doo doo doo doo
Oh I want something just like this
Doo doo doo doo doo doo

Doo doo doo doo doo
Doo doo doo doo doo doo

Where‘d you wanna go
How much you wanna risk
I‘m not looking for somebody
With some Superhuman gifts
Some Superhero
Some fairytale bliss
Just something I can turn to
Somebody I can kiss
I want something just like this

Oh I want something just like this

Oh I want something just like this

Oh I want something just like this‘‘‘

a = re.split("[\s+\n\.\,\‘]", new)
print(a)
import requests
from bs4 import BeautifulSoup as bs
import re


def req(url):
    res = requests.get(url=url)
    return res

def get_hit(res):
    html = res.content.decode(utf-8)
    hit_num = html.split(.html)[-1][2:-3]
    print(hit_num)

def page_url(res):
    soup = bs(res.content.decode(utf-8), html.parser)
    page_url = soup.select(.news-list li a)
    return page_url

if __name__ == __main__:
    url = http://news.gzcc.cn/html/xiaoyuanxinwen/
    j_url = http://oa.gzcc.cn/api.php?op=count&id={}&modelid=80
    res = req(url)
    page_url = page_url(res)
    for p in page_url:
        p_url = p.get(href)
        id = re.findall((\d+/\d+),p_url)[0].split(/)[1]
        p_res = req(j_url.format(str(id)))
        get_hit(p_res)

 

使用正则表达式,取得点击次数,函数抽离

标签:clip   api   can   函数   正则表达式   sel   search   iss   hat   

原文地址:https://www.cnblogs.com/lzhshuai/p/8758727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!