from bs4 import BeautifulSoup as bf
import requests
url ='https://www.soxscc.com/MangHuangJi/'
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"}
html = requests.get(url,headers=headers)
texts = html.text
soup = bf(texts,'lxml')
content = soup.findAll('a')
for i in content:
print(i)
![](https://img.haomeiwen.com/i4513441/ba75dac2e4ebfea8.png)
爬取了标签a,现在问题1是要爬取出href,问题2是其中还有不属于章节网址,还是不会连续。
之后我添了代码
for i in content:
hr = i.get('href')
print(hr)
得到
![](https://img.haomeiwen.com/i4513441/c908203fa0b00fa9.png)
可以看到隔一段就有一个蓝色的网址,影响我爬取文字。还不知道怎么解决。
网友评论