无法检索爬网信息

时间:2020-10-28 07:50:51

标签: python

image of output

从图片的结果屏幕中可以看到,类名是正确的,似乎没有错误。但是我没有任何结果。

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)

3 个答案:

答案 0 :(得分:0)

enter image description here

翻译。无法再以这种方式对网站进行爬网。

答案 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)
相关问题