代码拉取完成,页面将自动刷新
#参考自http://c.biancheng.net/view/2011.html
import requests #导入requests包
from bs4 import BeautifulSoup
import re
import time
url='https://xingzhengquhua.51240.com/130101000000__xingzhengquhua/'
strhtml=requests.get(url)
soup=BeautifulSoup(strhtml.text,'lxml')
data = soup.select('#main_content > table > tr > td > table > tr')
print(data)
for item in data[3:]:
time.sleep(0.1)
result={
'title': re.findall('\D+', item.get_text()),
'ID': re.findall('\d+', item.get_text())
}
print(result)
for item in data[3:]:
time.sleep(0.1)
result = {
'title': re.findall('\D+', item.get_text()),
'ID': re.findall('\d+', item.get_text())
}
print(result)
print('程序执行结束')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。