Ask coding questions

← Back to all posts
Call Repl.it from Apps Script
HerreraCarlos81 (0)

Hello community

I have this repl.it python code which is supposed to make some scrapping and return the price of the item.
https://replit.com/@HerreraCarlos81/Harrods-Tracker-Amazon-Scrap#main.py

I want to call it using apps script with something like:
UrlFetchApp.fetch("https://replit.com/@HerreraCarlos81/Harrods-Tracker-Amazon-Scrap#main.py");

And return the output of the scrap as a result to the apps script which is running.

Is that possible? Anywhere I can read how to do it?

Comments
hotnewtop
19ecal (228)

You can have a flask server like so

from flask import *
def scrape():
    #your code for scraping here
    return scraped_output
app=Flask ("main")
@app.route("/")
def main():
    return scrape()
app.run(host="0.0.0.0")

Then you can fetch to that URL
It will be like this repl-name.username.repl.co

19ecal (228)

So if you name the repl scrapingserver
You can fetch it at
scrapingserver.herreracarlos81.repl.co

HerreraCarlos81 (0)

@19ecal did a basic call to test it out but it only works inside repl.it, not when I call it from a browser with the url:

https://amazon-selenium-navigator.herreracarlos81.repl.co/

The result:

This site can’t be reached
amazon-selenium-navigator.herreracarlos81.repl.co took too long to respond.

this is the new repl.it which I changed just to test the return
https://replit.com/join/zhbystzk-herreracarlos81

Any clues what I am doing wrong?

19ecal (228)

@HerreraCarlos81 are you using selenium or beautifulsoup

HerreraCarlos81 (0)

@19ecal I have made an attempt with both to figure out the best way to approach this scrapping, and both work fine until I add the flask server part. That is why I think the problem is with my set up of the server. If you run my selenium repl.it, it shows lots of errors

HerreraCarlos81 (0)

@HerreraCarlos81 I just figured out what I was missing and it works with beautifulsoup! Awesome. Will try to make same adjustment to see if I can get Selenium to work as well.

The problem was with my Python return code itself 🤦‍♂️, I hadn't noticed that before since I was just printing the result and not returning.

HerreraCarlos81 (0)

@19ecal Selenium fork still does not work 😥. I get a 500 error when trying to load on the browser while the flask server is running.

https://replit.com/join/zhbystzk-herreracarlos81

19ecal (228)

@HerreraCarlos81 You probably will have to stick with beautifulsoup then

HerreraCarlos81 (0)

@19ecal Got it. Thanks a lot for the support on the flask code.