浏览次数的查看

import re
import requests

newsurl = 'http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0925/8249.html'

def getClickCount(newsurl):
mymach = re.match('http://news.gzcc.cn/html/2018/xiaoyuanxinwen_(.*).html', newsurl).group(1).split("/")[-1]
print(mymach)

mysearch = re.search('\_(.*).html', newsurl).group(1)
print(mysearch)

myfindall = re.findall('\_(.*).html', newsurl)[0]
print(myfindall)

newId = re.findall('\_(.*).html', newsurl)[0].split('/')[-1]
res = requests.get('http://oa.gzcc.cn/api.php?op=count&id={}&modelid=80'.format(newId))
print(res.text.split(".html")[-1].lstrip("('").rsplit("')")[0])


getClickCount(newsurl)
posted @ 2018-04-10 16:20  QH.Thomas  阅读(260)  评论(0编辑  收藏  举报