我正在尝试解析来自某个电报通道的图像,例如https://t.me/versusbattlerus,图像就在这个块上 “img class="tgme_page_photo_image" src="https://... " but every time method returns different and not working links, why this happens? I'am using python 3.6, urllib, beautifulsoup4
方法
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()
这个脚本对我有效,请为测试提供“断开”链接。你知道吗
如果有bug,请尝试简单的Linux Shell解决方案:
相关问题 更多 >
编程相关推荐