Spider
import requests
from bs4 import BeautifulSoup
while True:
try:
def trade_spider(max_pages):
page = 1
while page <= max_pages
url = 'https://forum.softpedia.com/forum/270-incepatori/page__st__200'+str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link is soup.findAll('a', {'class': 'itemprop=name'}):
href = "https://forum.softpedia.com" + link.get('href')
title = link.string
#print(href)
#print(title)
get_single_item_data(href)
page += 1
def get_single_item_data(item_url):
source_code = requests.get(item_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for item_name in soup.findAll('div', {'clas': 'i-name'}):
print(item_name.string)
for link in soup.findAll('a'):
href = "https://forum.softpedia.com" + link.get('href')
print(href)
break
except ValueError:
print("Something goes wrong")
finally:
print("loop completed")
trade_spider(3)