【发布时间】:2021-10-07 03:52:18
【问题描述】:
我正在抓取该网站的网址,但是当我尝试检索所有网址时,我不断收到错误消息 这是带有网址的源页面 [![这是带有url的页面的源代码][1]][1]
我得到了这个代码的第一个网址
soup_bookstore.find('td' , style = "text-align: center;").a.get('href')
这是结果[![在此处输入图像描述][2]][2]
然后我尝试使用此代码检索其余部分
book_urls = [x.a.get('href') for x in soup_bookstore.find('td' , style = "text-align: center;")]
# Display number of fetched URLs
print(str(len(book_urls)) + " fetched book URLs")
# We can print all fetched URLS
for book in book_urls:
print(book)
我不断收到此错误 [![在此处输入图片描述][3]][3]
我的目标是检索每个课程名称下的所有 url 以放入 pandas 数据框 [1]:https://i.stack.imgur.com/TtsUN.png [2]:https://i.stack.imgur.com/pGdYL.png [3]:https://i.stack.imgur.com/8PelX.png
【问题讨论】:
-
您的帖子基本上无法阅读。删除所有图片并改用文字。
-
一些
td不包含a,所以你不能调用x.a.get()
标签: python html web-scraping data-science data-mining