I am trying to output some scraped data from a webpage (vlr.gg) to WhatsApp,according to the input given by user.
I am trying to return some scraped values from a webpage (vlr.gg). The objective is to return some specific values according to user input.
from flask import Flask,request,render_template,make_response,Response
from googlesearch import search
import requests
from twilio.twiml.messaging_response import MessagingResponse
from vlrggbot import matches,choice
app = Flask(__name__)
@app.route("/", methods=["POST"])
def bot():
user_msg = request.values.get('Body', '').lower()
response = MessagingResponse()
msg=response.message("demo")
msg=response.message("demo")
msg=response.message("demo")
if user_msg=="matches":
print(1)
msg=response.message(f"Upcoming Matches: n")
z=1
c=0
mn=matches()
msg=response.message("1. ",mn[0]," vs.",mn[1])
msg=response.message("2. ",mn[2]," vs.",mn[3])
msg=response.message("3. ",mn[4]," vs.",mn[5])
msg=response.message("4. ",mn[6]," vs.",mn[7])
msg=response.message("5. ",mn[8]," vs.",mn[9])
msg=response.message("real")
# print (response)
return Response(str(response),mimetype="application/xml")
if __name__ == "__main__":
app.run()
The response.message
statements inside the if block do not return anything. However the response.message
that print “demo” outside the if block do work. If I try the same within the if block, it does not work. I have tried printing the response
, this is what i get:
<?xml version="1.0" encoding="UTF-8"?><Response><Message>demo</Message><Message>demo</Message><Message>demo</Message><Message>Upcoming Matches:
</Message><Message action="Corn Dawgs" from=" vs." to="Bandit ESC">1. </Message><Message action="SweetNsour" from=" vs." to="apinaorkesteri">2. </Message><Message action="TSM" from=" vs." to="M80">3. </Message><Message action="Six Karma" from=" vs." to="POLARITY">4. </Message><Message action="Blinn" from=" vs." to="Turtle Troop">5. </Message><Message>real</Message></Response>
So the values are in response, but for some reason it doesnt output anything to me on WhatsApp other than “demo”
I checked the Twilio debugger, it says “11100-Invalid URL Format” everytime.
There is no error on the ngrok console or inspectcer it says:
HTTP Requests ------------- POST / 200 OK POST / 200 OK
Any help is appreciated
Priyanshu Lahiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.