-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_scrapper.py
68 lines (46 loc) · 1.62 KB
/
web_scrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import requests
from bs4 import BeautifulSoup
def get_newsV2():
news = {}
url = "https://www.cariverplate.com.ar/noticias-de-entradas"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
eq = soup.findAll("a", class_="titulo")
for x in eq:
news_url = "https://www.cariverplate.com.ar/" + x["href"]
page = requests.get(news_url)
soup2 = BeautifulSoup(page.content, "html.parser")
title = "**" + x.text + "**"
eq2 = soup2.find("figcaption")
eq3 = eq2.findAll("p")
full_text = ""
for y in eq3:
eq4 = y.findAll("strong")
bolds_processed = []
for string in eq4:
text = string.text
new_string = text.replace("<strong>", "")
new_string = new_string.replace("</strong>", "")
bolds_processed.append(new_string)
new_text = y.text
if new_text in bolds_processed:
new_text = "**" + new_text + "**"
full_text = full_text + new_text + "\n"
print(y)
print(full_text)
print("\n")
print("\n")
break
news[title] = full_text
return news
def get_newsV1():
news = {}
url = "https://www.cariverplate.com.ar/noticias-de-entradas"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
eq = soup.findAll("a", class_="titulo")
for x in eq:
news_url = "https://www.cariverplate.com.ar/" + x["href"]
title = u'🚨' + x.text
news[title] = news_url
return news