在Beautifuresoup Python Web刮板中获得错误的链接
我正在编写网络刮板,并正在努力从网页上获取HREF链接。 URL为 https://www.seedinvest.com/auto 我试图获得HREF链接他们的个人文章。这是一个示例:
<a class="card-url full-size-content" href="https://www.seedinvest.com/soil.connect/seed"></a>
这是我的代码:
import pandas as pd
import os
import requests
from bs4 import BeautifulSoup
import re
URL = "https://www.seedinvest.com/offerings"
page = requests.get(URL)
soup = BeautifulSoup(page.text, "html.parser")
### Searching for all embeded company website links and displaying them
links = []
for link in soup.findAll(class_="card-url full-size-content"):
links.append(link.get('href'))
print(links)
当我运行代码时,我得到了:
[]
您能帮我找到正确的链接吗?
I am writing a web scraper and am struggling to get the href link from a web page. The URL is https://www.seedinvest.com/auto I am trying to get the href links of their individual articles. Here is an example:
<a class="card-url full-size-content" href="https://www.seedinvest.com/soil.connect/seed"></a>
Here is my code:
import pandas as pd
import os
import requests
from bs4 import BeautifulSoup
import re
URL = "https://www.seedinvest.com/offerings"
page = requests.get(URL)
soup = BeautifulSoup(page.text, "html.parser")
### Searching for all embeded company website links and displaying them
links = []
for link in soup.findAll(class_="card-url full-size-content"):
links.append(link.get('href'))
print(links)
When I run my code, I get this:
[]
Can you help me find the right links?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它在
。
It's working in url
Output:
也许您在代码中使用了错误的URL:
https://www.seedinvest.com/offerings
而不是https://www.seedinvest.com/auto
?Maybe you're using the wrong URL in your code:
https://www.seedinvest.com/offerings
instead ofhttps://www.seedinvest.com/auto
?