我'试图从一些电报信道解析图像,如实施例https://t.me/versusbattlerus,该图像是该块上 “IMG类=” tgme_page_photo_image” SRC =‘HTTPS:// ...’,但每次方法返回不同的,而不是建立工作联系,为什么会这样使用python 3.6,urllib的? 我',beautifulsoup4解析HTTP返回断开链路
方法
import urllib.request
from bs4 import BeautifulSoup
def get_html(url):
response = urllib.request.urlopen(url)
return response.read()
def parse(html):
soup = BeautifulSoup(html, 'lxml')
image = soup.find('img', class_="tgme_page_photo_image")
print(image)
#return image
def main():
parse(get_html('https://t.me/versusbattlerus'))
if __name__ == '__main__':
main()
这正常工作与我 – chad