Irtiza Hammad Irtiza Hammad - 2 months ago 27
HTTP Question

Run a Python script on my website

I am using

to scrape data from websites.

My code works when I run it from PyCharm.

When I run it on my website (like
) it does not run.

How can I run my code on my site?

import requests
from bs4 import BeautifulSoup

def trade_spider(max_pages):

page = 1

while page <= max_pages:
url = ''+ str(page)
source_code = requests.get(url, allow_redirects=False)
plain_text = source_code.text.encode('ascii', 'replace')
soup = BeautifulSoup(plain_text, 'html.parser')

for div in soup.findAll('div', {'class': 'geo-zoom-effect'}):
for a in div.findAll('a'):
title = a.get('title')
href = a.get('href')
print title
print href

for img in a.findAll('img'):
print src




000webhost is a Webhost that serves HTML,CSS, PHP and MySQL files and is not a Python host.

Digital Ocean is a fairly cheap ($5/month) and reliable VPS if you're looking for a full UNIX environment and host your Python files.

If not familiar or want free I'll recommend PythonAnywhere or OpenShift