-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrape.py
43 lines (33 loc) · 840 Bytes
/
scrape.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
import requests
from bs4 import BeautifulSoup
URL = "https://cctools.readthedocs.io/en/stable/taskvine/"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")
section = soup.find("div", class_ = "section")
highlights = section.find_all("pre", class_="highlight")
f = open('quickstart.py','a')
#scraping for 'quickstart.py'
i = 0
for highlight in highlights:
if i == 2:
f.write(highlight.text)
break
i = i+1
f.close()
f = open('conda-inst.sh', 'a')
#scrape for ndcctools install
i = 0
for highlight in highlights:
if i == 1:
f.write(highlight.text + " -y")
break
i = i+1
#scrape for 'python quickstart.py'
f.close()
f = open('run-python.sh', 'a')
i = 0
for highlight in highlights:
if i == 3:
f.write(highlight.text)
break
i = i+1