首页 > 解决方案 > 如何获取soup代表的url?

问题描述

BeautifulSoup之后如何获取页面的url?

res = requests.get('http://www.example.com')
soup = BeautifulSoup(res.text, 'lxml')

如何http://www.example.com从汤中获得?

标签: pythonbeautifulsoup

解决方案


试试这个:

soup.url = 'http://www.example.com'

传递soup给函数后,您可以调用soup.urlget http://www.example.com


推荐阅读