-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetlist.py
executable file
·45 lines (35 loc) · 1.03 KB
/
getlist.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
#! /usr/bin/env python3
import requests
import config
import os
from bs4 import BeautifulSoup
import re
data = {'login':config.user, 'password':config.password}
begin = requests.Session()
headers = {'Content-type':'application/json'}
req = begin.post(config.login_url, json = data, headers=headers)
print(req.text)
i = 0
f = open('/home/worker/vendingautm/finally', 'w')
f.write("")
f.close
while i!=config.pages:
r = begin.get(config.get_list_url + str(i))
soup = BeautifulSoup(str(r.text), 'html.parser')
r = r.text
table = soup.find('tbody')
r = str(table)
final = BeautifulSoup(str(r),'html.parser')
for a in final("a"):
a.decompose()
for script in final(["script", "style"]):
script.decompose()
for td in final("td"):
td.find_all('td')
all_text = ''.join(final.findAll(text=True))
r = str(all_text)
file = open('/home/worker/vendingautm/finally', 'a')
file.write(r)
file.close()
i+=1
os.system("sed -i '/^$/d' /home/worker/vendingautm/finally ")