テレグラムチャンネルの画像を解析しようとしています。例:https://t.me/versusbattlerus、画像はこのブロックにあります。 "img class =" tgme_page_photo_image "src =" https:// ... "毎回の方法が異なるといない作業のリンクを返します。このスクリプトは私に取り組んでいますhttpを解析すると、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