我试图访问一个类HTML中唯一的文本。我试图应用于 BeautifulSoup,但总是收到相同的错误消息或该标记中的所有项。
My code.py
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
import re
url = "https://www.auchandirect.pl/auchan-warszawa/pl/pepsi-cola-max-niskokaloryczny-napoj-gazowany-o-smaku-cola/p-98502176"
r
我正在尝试刮,一个使用python的网站。但我会跟着错误走。
回溯(最近一次调用):文件"c:\Users\My PC Buddy\python\scraper\scraper.py",第11行,在link = product.find("a",{“class”:“product.find”}).get(‘href’) AttributeError:'NoneType‘对象没有属性'get’中
以下是我的代码
import requests
from bs4 import BeautifulSoup
import pandas as pd
bas
这是im的代码,最初用于提取左上角的时间。
import qgrid
import webbrowser
import requests
from bs4 import BeautifulSoup
page = requests.get('http://www.meteo.gr/cf.cfm?city_id=14') #sending the request to take the html file.
soup = BeautifulSoup(page.content, 'html.parser') #creating beautifulSoup
我想从《纽约时报》网站上获得一些头条。我有两个问题,问题1:这是我的代码,但我没有给我任何输出,有人知道我必须修改什么吗? import requests
from bs4 import BeautifulSoup
url = 'https://www.nytimes.com'
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")
a = soup.find_all(class_="balancedHeadline")
for story_heading in a:
我试图解析一组txt文件的url,但是Beautiful Soup只返回最后一个url的内容。这是一组来自LetterBoxD网站的带有电影评论的urls。例如,如果文件有10个urls,我得到的前9个urls是"none“,只有第10个是正确返回的。有人能帮我吗? from bs4 import BeautifulSoup
import requests
with open('list_of_urls.txt', 'r') as f:
x = f.readlines()
for url in x:
page = requests.get(
我试图使用BeautifulSoup将for循环的特定迭代(在“位置”变量中)的URL分配给变量,但我不明白为什么它不能工作(输出是完整的列表--我只想要所选的列表)。任何帮助都是非常感谢的。谢谢!
position = int(input('Enter position:'))
n = int(0)
tags = soup('a')
for tag in tags:
if n<position:
n=n+1
else:
x=tag.get('href', None)
pri
使用一个加密货币小部件,它实时地为特定的加密货币价格抓取html,但是运行在AttributeError上:'NoneType‘对象没有属性'find’。
这件事突然发生了,我真搞不懂为什么它来得不快。在此之前,我已经多次运行代码,绝对没有问题。我的两个问题是..。
为什么会突然发生这种事?
和
我该怎么解决这个问题?
from tkinter import *
import requests
from bs4 import BeautifulSoup
from tkinter.ttk import *
from time import strftime
def get_c
import requests
from bs4 import BeautifulSoup
from lxml import etree
import csv
with open('1_colonia.csv', 'r', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
next(reader) # skip the header row
for row in reader:
url =
我正在尝试使用Selenium的Webdriver.execute_script()从Reddit的主页中获取元素列表。(在您推荐PRAW之前: Reddit实际上并不是我想从其中获取元素,我只是以它为例。)
尽管我在Chrome的dev工具控制台中运行它时,执行的脚本工作得很好,Selenium的方法只返回一个空列表,这个列表应该用Reddit posts的title元素填充。
import urllib
from selenium import webdriver
from BeautifulSoup import BeautifulSoup
#Path to the chromedri
我在使用Beautifulsoup解析带有"class“属性的HTML元素时遇到了问题。代码如下所示
soup = BeautifulSoup(sdata)
mydivs = soup.findAll('div')
for div in mydivs:
if (div["class"] == "stylelistrow"):
print div
在脚本结束后,我在同一行得到了一个错误。
File "./beautifulcoding.py", line 130, in getlanguage