Some webpages not working on Replit?

Hi! I’m kind of new to replit, and I was trying to gather data from this website: https://hadith.inoor.ir/ar/home via BeautifulSoup, however I get the following error: “Connection to hadith.inoor.ir timed out.”

At first I assumed that this was an issue with the JavaScript, so I ran it using Selenium but received the same error. Then I ran it using VS Code and it worked exactly how I wanted it to. Which led me to the conclusion that Replit was the problem.

Currently my hypothesis is that iranian websites have a hard time working with Replit, I say this because I’ve tried multiple other iranain websites and received the same error. I personally don’t really care about the iranian thing, I just need the data on the website. Thanks!

import requests
from bs4 import BeautifulSoup

def sol(link):
  r = requests.get(link)
        
  soup = BeautifulSoup(r.content, "html.parser")

  title = soup.find("h2")
  title = title.get_text()
  print(title)


print(sol("https://hadith.inoor.ir/fa/home"))
2 Likes

IIRC Replit doesn’t have servers in Iran.

And Python will get these two vars mixed up HORRIBLY when you run. Try replacing them with this:

 title = soup.find("h2")
 title_1 = title.get_text()
1 Like

Thanks for the response!

Hmm… Do you know of any possible workarounds to this? I don’t really have the option of switching IDE’s

Gotcha!

1 Like

Sorry, I don’t :confused: . A recommendation would be to use a VPN and try to find a solution to your problem. I looked up how to scrape Iranian websites and only got this blog post by Google.

Good luck!

2 Likes

BRO I LITERALLY LOVE YOU! This proxy does the trick!

1 Like

Ay anytime man. Glad to help.