我'試圖從一些電報信道解析圖像,如實施例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