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

Posted 117李智濠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用正则表达式,取得点击次数,函数抽离相关的知识,希望对你有一定的参考价值。

import re

a = "[email protected]"
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)

 

以上是关于使用正则表达式,取得点击次数,函数抽离的主要内容,如果未能解决你的问题,请参考以下文章

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

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

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

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

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

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