Issue
here i'm using flask api module
@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)
when i give
http://127.0.0.1:5000/url?url=https://stackoverflow.com it's not scraping the webpage , but it's perfectly working with out API
like example
html = requests.get(web_url).text
soup = BeautifulSoup(html, 'lxml')
web_page = soup.get_text().strip()
print(web_page)
and here i just make
import request as requests
is that will a issue.? with request.args
i just need the scraped web page html code as a output that is i'm searching
like when we do on google crome view page source
like that way i'm trying to get output
any suggestions
Solution
you should import request from flask and to send the request you, need to import requests
import flask # to get the args and run the http server
import requests # to send the get request
@app.route('/url', methods=['GET'])
def api_url():
if 'web_url' in flask.request.args:
web_url = str(flask.request.args['web_url'])
html = requests.get(web_url).text
soup = BeautifulSoup(html, 'lxml')
web_page = soup.get_text().strip()
return (web_page)
Answered By - Mangisto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.