我正在尝试用Python创建一个简单的Web爬虫程序,当我运行它时,它不会显示任何错误,但也不会按预期打印任何结果。 我已经把我现在的代码放在下面了,有人能告诉我问题的方向吗?你知道吗
import requests
from bs4 import BeautifulSoup
def stepashka_spider(max_pages):
page = 1
while page <= max_pages:
url = "http://online.stepashka.com/filmy/#/page/" + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for resoult in soup.findAll("a", {"class": "video-title"}):
href = resoult.get(href)
print(href)
page += 1
stepashka_spider(1)
"video-title"
在div标记中,还需要传递字符串"href"
:输出:
您实际上使用了错误的url格式,我们也可以使用范围而不是循环:
输出:
相关问题 更多 >
编程相关推荐