【发布时间】:2021-01-29 03:37:02
【问题描述】:
我正在尝试构建一个爬虫,我想打印该页面上的所有链接 我正在使用 Python 3.5
这是我的代码
import requests
from bs4 import BeautifulSoup
def crawler(link):
source_code = requests.get(link)
source_code_string = str(source_code)
source_code_soup = BeautifulSoup(source_code_string,'lxml')
for item in source_code_soup.findAll("a"):
title = item.string
print(title)
crawler("https://www.youtube.com/watch?v=pLHejmLB16o")
但我得到这样的错误
TypeError Traceback (most recent call last)
<ipython-input-13-9aa10c5a03ef> in <module>()
----> 1 crawler('http://archive.is/DPG9M')
TypeError: 'module' object is not callable
【问题讨论】:
-
你试过重命名你的
crawler方法吗? -
是的,我把“crawler”改成了“cat”,还是一样的错误
标签: python web-crawler