Python,Beautifullsoup-获取href链接

Python,Beautifullsoup-获取href链接,python,python-3.x,beautifulsoup,Python,Python 3.x,Beautifulsoup,我有一个问题,我试图从网站下载链接,但它没有返回任何链接。我不知道我做错了什么。。。有人能帮帮我吗??THX !/usr/bin/python3 -*-编码:utf-8-*- 导入请求 从bs4导入BeautifulSoup 第页=https://mojmikolow.pl/informacje,0.html page=requests.getpage.content data_entries=beautifulsoupage,html.parser.find_allsection,{class

我有一个问题,我试图从网站下载链接,但它没有返回任何链接。我不知道我做错了什么。。。有人能帮帮我吗??THX

!/usr/bin/python3 -*-编码:utf-8-*- 导入请求 从bs4导入BeautifulSoup 第页=https://mojmikolow.pl/informacje,0.html page=requests.getpage.content data_entries=beautifulsoupage,html.parser.find_allsection,{class:news} 对于数据项中的数据项: get_link=data_entrie.get'href' printget_链接 您可以使用提取所有链接标记,然后从每个链接标记中获取href属性的值:

from bs4 import BeautifulSoup

import requests

page = "https://mojmikolow.pl/informacje,0.html"
page = requests.get(page).content
data_entries = BeautifulSoup(page, "html.parser").find_all("section", {"class": "news"})

for data_entry in data_entries:    
    links = data_entry.find_all("a", href=True)
    for link in links:
        print(link["href"])
您可以使用提取所有链接标记,然后从每个链接标记中获取href属性的值:

from bs4 import BeautifulSoup

import requests

page = "https://mojmikolow.pl/informacje,0.html"
page = requests.get(page).content
data_entries = BeautifulSoup(page, "html.parser").find_all("section", {"class": "news"})

for data_entry in data_entries:    
    links = data_entry.find_all("a", href=True)
    for link in links:
        print(link["href"])

您必须拉出包含href的锚定标记:

导入请求 从bs4导入BeautifulSoup 第页=https://mojmikolow.pl/informacje,0.html page=requests.getpage.content data_entries=beautifulsoupage,html.parser.find_allsection,{class:news} 对于数据项中的数据项: link\u tag=data\u entrie.find'a',href=True 获取链接=链接标签。获取href printget_链接
您必须拉出包含href的锚定标记:

导入请求 从bs4导入BeautifulSoup 第页=https://mojmikolow.pl/informacje,0.html page=requests.getpage.content data_entries=beautifulsoupage,html.parser.find_allsection,{class:news} 对于数据项中的数据项: link\u tag=data\u entrie.find'a',href=True 获取链接=链接标签。获取href printget_链接 副本的副本