【发布时间】:2023-12-29 14:27:01
【问题描述】:
这里我用的是flask api模块
@app.route('/url', methods=['GET'])
def api_url():
if 'web_url' in request.args:
web_url = str(request.args['web_url'])
html = requests.get(web_url).text
soup = BeautifulSoup(html, 'lxml')
web_page = soup.get_text().strip()
return (web_page)
当我给予时
http://127.0.0.1:5000/url?url=https://*.com 它不是在抓取网页,而是在没有 API 的情况下完美运行
喜欢的例子
html = requests.get(web_url).text
soup = BeautifulSoup(html, 'lxml')
web_page = soup.get_text().strip()
print(web_page)
我只是在这里制作import request as requests 这会是个问题吗?与request.args
我只需要抓取的网页 html 代码作为我正在搜索的输出
就像我们在google crome view page source 上做的那样,我试图获得输出
任何建议
【问题讨论】:
标签: python flask beautifulsoup python-requests