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

re.match("(\w)+@(\w{2,4}).[a-z]{3,4}","linweicong@sohu.com")#邮箱
re.match("^(\d){3}-(\d){8}$","321-84124291")#电话
def onclick(url):
    identify = re.search("_(\d+)/(\d+)",url).group(2)
    url1 = "http://oa.gzcc.cn/api.php?op=count&id={}&modelid=80".format(identify)
    ress = requests.get(url1)#相对应的编号通过此url可以获取点击数!!!点击数是通过这url来接受服务器返回的消息
    ress.encoding="utf-8"
    soup = BeautifulSoup(ress.text,"html.parser")
    click = re.findall("html\('(\d+)'\)",str(soup))[-1]
    print(click)

 

posted on 2018-04-09 20:35  121林伟聪  阅读(121)  评论(0编辑  收藏  举报