for link in soup.find_all('a', {'class': 'post-tag'}): # href = link.get('href') for i in link: title = link.string print(title)
输出: python浮点舍入python非谷歌合作python flask python漂亮汤python nonetype python ubuntu等。
在从堆栈溢出站点提取数据时,我们在抓取问题的标签
我是python的初学者,只有几个星期在尝试做我的网络抓取。我需要在tripadvisor上抓取一家餐厅的多个页面,在windows32上使用漂亮的汤。在每个页面中,我需要记录餐厅名称、社会等级和菜肴/菜肴、客户名称、日期评论、滴滴评论和评论。
我在python控制台中尝试了以下代码:
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
for i in range(260,1231):
my_url = "https://www.tripadvisor.fr/Res
我想做一些我不知道是不是很丑的事.
我试图做一些网络抓取,我假装概括了一个函数来提取正确的类。
守则是:
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/
我正在尝试用漂亮汤编写一个非常简单的python脚本
import smtplib
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
import sched, time
s = sched.scheduler(time.time,time.sleep)
my_url = 'https://finance.yahoo.com/quote/USDTRY=X/'
uClient = uReq(my_url)
page_html = uClient.read()
我一直在尝试开发一个将Wikipedia数据读取到JSON文件中的scraper类。我需要能够读取表格,从第一列提取链接,从这些链接检索信息,并使其成为JSON文件。我遇到的问题是,当我试图从表行中提取表数据时,我收到了错误消息,如NoneType has no attribute find_all。虽然我用一个页面测试了这个文件,它工作得很好,但在另一个页面上它却很困难。同时,同一类的其他函数在其他页面中也可以很好地工作。我也不能找出索引错误。 为了从第一列派生数据,我尝试过遍历行、表和soup对象。我在不同的情况下得到的结果如下:- NoneType没有属性find_all - str对
在以下链接中:
我需要获取h2、h3和p标记中的内容。但是,我想忽略标题和以下内容:
“又见”
“注释”
“参考”
忽略所有表/urls
我怎样才能在美丽的汤里做到这一点呢?我的当前代码如下:
def open_document():
for i in range (1, 1+1):
with open(directory_of_raw_documents + str(i), "r") as document:
html = document.read()
soup = B
四年前有人问过,但现在BS4的答案已经过时了。
我想要删除我的html文件中的所有评论使用美丽的汤。因为每个都是由BS4创建的,所以我认为下面的代码会起作用:
for comments in soup.find_all('comment'):
comments.decompose()
所以那不管用...如何使用BS4查找所有评论?
我有这段html,我想解析:
<div class="class123">
<div><strong>title123</strong>
<span style="something123">something else</span>
</div>
I want to parse this, how can do that?
</div>
我怎么才能用漂亮的汤来解析呢?我知道如何解析标签中的东西,但是如何在相同的层次上解析一些东西呢?
soup1