|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import requests
- import bs4
- import time
- pl = input("请输入要爬取的最新帖子的评论:")
- a = 1
- payload = {"mod":"guide","view":"newthread","page":1}
- res = requests.get("https://fishc.com.cn/forum.php", params=payload)
- sb = bs4.BeautifulSoup(res.text,features="lxml")
- mzli = sb.find_all("a",class_="xst")
- url = " "
- while True:
- res = requests.get("https://fishc.com.cn/forum.php", params=payload)
- sb = bs4.BeautifulSoup(res.text,features="lxml")
- mzli = sb.find_all("a",class_="xst")
- if not mzli:
- break
- else:
- for i in mzli:
- if i.text == pl:
- url = i["href"]
- payload["page"]+=1
- time.sleep(0.2)
- if url == " ":
- raise ValueError()
- req = requests.get(url)
- bs = bs4.BeautifulSoup(req.text,features="lxml")
- ta = bs.find_all("div",class_ = "t_fsz")
- for each in ta:
- print(each.table.text)
- print("------------------------------------------------------------")
- time.sleep(10)
复制代码
我无聊写的
有什么修改建议写下面 |
|