Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import csv
- def get_html(url):
- r = requests.get(url)
- r.encoding = 'utf8'
- return r.text
- def csv_read(data):
- with open("data.csv", 'header') as file:
- writer = csv.writer(file)
- writer.writerow((data['head'], data['link']))
- def get_link(html):
- soup = BeautifulSoup(html, 'lxml')
- head = soup.find('div', id='post').find_all('header', class_="post-header-title")
- for i in head:
- link = 'https://point.md/ru/novosti' + i.get('href')
- heads= i.find('h1').string
- data = {'head': heads,
- 'link': link}
- csv_read(data)
- data = get_link(get_html('https://point.md/ru/novosti'))
Add Comment
Please, Sign In to add comment