Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<&燃气轮机;改为&;lt&;燃气轮机;并且find“u all”(“a”)无法在python中提取带有beautifulsoup的链接_Python_Beautifulsoup - Fatal编程技术网

<&燃气轮机;改为&;lt&;燃气轮机;并且find“u all”(“a”)无法在python中提取带有beautifulsoup的链接

<&燃气轮机;改为&;lt&;燃气轮机;并且find“u all”(“a”)无法在python中提取带有beautifulsoup的链接,python,beautifulsoup,Python,Beautifulsoup,我正在尝试使用BeautifulSoup提取一些链接 下面是我使用的python代码 resp = urlopen("http://target-page.com").read().decode("utf-8") soup = BeautifulSoup(resp, "html.parser") all_links = soup.find_all("a") for link in all_links: print(link["href"]) 下面是我通过print(“soup”) a

我正在尝试使用BeautifulSoup提取一些链接

下面是我使用的python代码

resp = urlopen("http://target-page.com").read().decode("utf-8")
soup = BeautifulSoup(resp, "html.parser")
all_links = soup.find_all("a")
for link in all_links:
    print(link["href"])
下面是我通过
print(“soup”)


a href=”http://bbb.com“target=“\u blank”
我可以得到“但不能”

为什么<>更改为
(仅在此分区中)?如何修复它

提前谢谢你的帮助

all_links2 = soup.find_all("div")
for link in all_links:
    print(link["href"])
**for link in all_links2:
    print(link["href"])**
您查看了所有-->a标记(例如以开头的标记) 但您要查找的页面存储在 您查看了所有-->a标记(例如以开头的标记)
但您要查找的页面存储在一个有趣的问题:-)您确定原始源不是这样的吗?或者,这些链接之间可能存在一些主要的html语法错误?我仔细检查了原始html代码,这是正确的:-(我查看了页面及其代码,在Chromeget中删除了相应的解码。bs4将为您解决此问题。嗯,有趣的问题:-)您确定原始源代码不是这样的吗?或者这些链接之间可能存在一些主要的html语法错误?我仔细检查了原始html代码,这是正确的:-(我在Chromeget中查看了页面及其代码,删除了相应的解码。bs4将为您完成此操作。
all_links2 = soup.find_all("div")
for link in all_links:
    print(link["href"])
**for link in all_links2:
    print(link["href"])**