【发布时间】:2018-11-11 00:54:01
【问题描述】:
#!/usr/bin/env python
import requests
from bs4 import BeautifulSoup
url = "https://www.youtube.com/channel/UCaKt8dvEIPnEHWSbLYhzrxg/videos"
response = requests.get(url)
# parse html
page = str(BeautifulSoup(response.content))
def getURL(page):
"""
:param page: html of web page (here: Python home page)
:return: urls in that page
"""
start_link = page.find("a href")
if start_link == -1:
return None, 0
start_quote = page.find('"', start_link)
end_quote = page.find('"', start_quote + 1)
url = page[start_quote + 1: end_quote]
return url, end_quote
while True:
url, n = getURL(page)
page = page[n:]
if url:
print(url)
else:
break
我正在使用上面的代码来获取网页上所有 youtube 视频的列表。如果我尝试这样做。我收到以下错误
The code that caused this warning is on line 9 of the file C:/Users/PycharmProjects/ReadCSVFile/venv/Links.py. To get rid of this warning, change code that looks like this:
我做了并开始使用 html,但出现了一些不同的错误。
我正在使用 Python 3.0 。我正在使用 IDE Pycharm。
谁能帮帮我。
【问题讨论】: