Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

求助,python爬虫解析html定位不到标签

想定位class为j_th_tit 的"a"标签,但是返回为空,是哪里写错了吗?万分感谢,代码和截图附上

from bs4 import BeautifulSoup
import urllib.request
from urllib.robotparser import RobotFileParser
from pyquery import PyQuery as pq
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

html = '''
"<a rel="noreferrer" href="/p/6077550005" title="这一次" target="_blank" class="j_th_tit ">这一次</a>"
'''
bs = BeautifulSoup(html,"html.parser")
get_href_list = bs.find_all("a",class_="j_th_tit ")
print(get_href_list)

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

19行的函数第二个参数,把 j_th_tit 后面的空格去掉.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...