Last active
July 24, 2023 13:53
-
-
Save KarimullinArthur/9ca519014a140d11437130a17681eb09 to your computer and use it in GitHub Desktop.
Habr Freelance Parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pprint | |
import requests | |
from bs4 import BeautifulSoup as bs | |
URL = 'https://freelance.habr.com/tasks' | |
categorie = '?categories=development_bots' | |
resp = requests.get(URL+categorie) | |
soup = bs(resp.text, "html.parser") | |
tasks = soup.find_all('article', class_='task task_list') | |
result = [] | |
for task in tasks: | |
dict = {} | |
dict['title'] = task.header.div['title'] | |
dict['url'] = URL[:-6]+task.header.div.a['href'] | |
dict['views'] = task.find_all('i', class_='params__count')[1].text | |
dict['responses'] = task.find_all('i', class_='params__count')[0].text | |
try: | |
dict['cost'] = task.find_all('span', class_='count')[0].text | |
except IndexError: | |
dict['cost'] = 'договорная' | |
result.append(dict) | |
pprint.pprint(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment