@IEATPYTHON/

Energy Diet Webscraper - Real-1

Python

No description

fork
loading
Files
  • main.py
  • requirements.txt
main.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
from requests_html import HTMLSession
import re


counter = 0
allvotes = [] 
voteorganization = [] 
session = HTMLSession()
r = session.get('http://energydiet.canadiangeographic.ca/2019/main/video_gallery')

links = r.html.links
reallinks = list(links)

for i in range(len(reallinks)):
  e = session.get(reallinks[counter])
  votes = [element.text for element in e.html.find(".video_info")] 
  votes = str(votes)
  votes = re.sub(r'.*/', '/', votes)
  votes = votes[85:]
  votes = votes[:-2]

  for i in range(2):
    votes = votes[votes.find("\\") + 1:]
    votes = votes[votes.find("n") + 1:]

  if "8C7" in votes:
    print('\033[93m','\033[1m', votes, '\033[0m')
    classvotes = votes 
    classvotes = classvotes[classvotes.find("\\") + 1:]
    classvotes = classvotes[classvotes.find("n") + 1:]
    classvotes = classvotes[:classvotes.find("v")]
    classvotes = int(classvotes)
    print(classvotes)

for i in range(len(reallinks)):
  e = session.get(reallinks[counter])
  votes = [element.text for element in e.html.find(".video_info")] 
  votes = str(votes)
  votes = re.sub(r'.*/', '/', votes)
  votes = votes[85:]
  votes = votes[:-2]

  for i in range(2):
    votes = votes[votes.find("\\") + 1:]
    votes = votes[votes.find("n") + 1:]

  if "8C7" in votes:
    print()
  else: 
    otherpersonvote = votes 
    otherpersonvote = otherpersonvote[otherpersonvote.find("\\") + 1:]
  otherpersonvote = otherpersonvote[otherpersonvote.find("n") + 1:]
  otherpersonvote = otherpersonvote[:otherpersonvote.find("v")]
  print(otherpersonvote)

  #else:
    #print(votes)   

  numvotes = votes[:-6]

  numvotes = votes[votes.find("n")+1:] 
 # print(numvotes)
  allvotes.append(votes)
  #voteorganization.append()
  #print(voteorganization)
  counter = counter + 1