我正在尝试抓取网页和大篮子信息,但我在使用findAll()函数时遇到问题。当我使用len(imgList)时,长度总是返回0。它总是显示空的列表,如何解决它?有人能帮我吗?我在grofer中得到了staus代码403 from bs4 import BeautifulSoup
url = 'https://grofers.com/cn/grocery-staples/cid/16'
driver = webdriver.Chrome(r'C:\Users\HP\data\chromedriver.exe')
driver.get(url)
html = dr
我试图执行以下python代码
import httplib2
from BeautifulSoup import BeautifulSoup, SoupStrainer
http = httplib2.Http()
status, response = http.request('http://www.nytimes.com')
for link in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
if link.has_attr('href'):
我正在使用Python3.4中的BeautifulSoup进行一些网络抓取。
现在,我在学习过程中遇到了一个问题:我试图从网页中获取一个表行,并且我使用find_all()来获取它们,但是在表中--有更多的表中有表行!如何在BeautifulSoup中只获得标签的顶级/一级通用或特定元素?
# Retrieves all the row ('tr') tags in table
my_table.find_all('tr')
顺便说一句,这个问题是这个问题的重复(只有在那里使用的编程语言是PHP):
我想做一些我不知道是不是很丑的事.
我试图做一些网络抓取,我假装概括了一个函数来提取正确的类。
守则是:
import requests, re
from bs4 import BeautifulSoup as bs
def has_label_key(tag):
print(tag)
return tag.has_attr("data-acc") and tag["data-acc"]=="WOTD"
s = requests.Session()
r = s.get("http://dle.rae.es/srv/
我试图刮谷歌新闻标题和他们的链接作为输入术语。但是,当我通过find_all方法搜索一个包含所有新闻标题的类时,它返回了一个空列表。
我试着用他们的身份证和父母的div,但结果并没有不同。
import requests
from bs4 import BeautifulSoup
input_term = input("Enter a term to search:")
source = requests.get("https://www.google.com/search?q={0}&source=lnms&tbm=nws".format(i
我刚开始吃蟒蛇和漂亮汤,如果这是个愚蠢的问题,我很抱歉。我试图创建一个,它以输入国家的名字命名,并从下面的网站()中找到它的货币供应。每当我试图查找所有a标记时,它都会给出以下错误:
"AttributeError: ResultSet object has no attribute 'find_all'.
You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()? "