标签:mode ext search html class bs4 pre amp import
import requests import re from bs4 import BeautifulSoup url="http://news.gzcc.cn/html/xiaoyuanxinwen/" res=requests.get(url) res.encoding="utf-8" url1="http://oa.gzcc.cn/api.php?op=count&id=9183&modelid=80" res1=requests.get(url1) print(res1.text.split(".html")[-1].lstrip("(‘").rstrip("‘);")) newUrl =‘http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0404/9183.html‘ re1 = re.search(‘\_(.*).html‘,newUrl) re2 = re.match(‘http://news.gzcc.cn/html/2018/xiaoyuanxinwen_(.*).html‘,newUrl) print(re1.group(1).split(‘/‘)[-1],re2.group(1).split(‘/‘)[-1])
标签:mode ext search html class bs4 pre amp import
原文地址:https://www.cnblogs.com/lg916843/p/8758677.html