从图片的结果屏幕中可以看到,类名是正确的,似乎没有错误。但是我没有任何结果。
from bs4 import BeautifulSoup
from urllib.request import urlopen
response = urlopen("https://www.naver.com")
soup = BeautifulSoup(response, 'html.parser')
for anchor in soup.select('span .realtime_item'):
print(anchor)
答案 0 :(得分:0)
翻译。无法再以这种方式对网站进行爬网。
答案 1 :(得分:0)
对我有用:
from bs4 import BeautifulSoup
from urllib.request import urlopen
response = urlopen("https://www.naver.com")
soup = BeautifulSoup(response, 'html.parser')
for anchor in soup.select('.realtime_item'):
print(anchor)
print("\n\n")
答案 2 :(得分:0)
您没有获取任何数据,因为SPAN没有 realtime_item 之类的东西。尝试打印汤并查找值是否存在,然后选择
from bs4 import BeautifulSoup
from urllib.request import urlopen
response = urlopen("https://www.naver.com")
soup = BeautifulSoup(response, 'html.parser')
print(soup)