Last active
April 5, 2018 19:14
-
-
Save undefinedzain/c46d6a99bf909814928554ab968308f3 to your computer and use it in GitHub Desktop.
Get resi data scraping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import sys | |
if len(sys.argv) < 3: | |
print ('Usage example : python resi_scraping.py tiki 030003437484 ') | |
else: | |
jasa = sys.argv[1] | |
noresi = sys.argv[2] | |
headers = { | |
'User-Agent': 'Mozilla/5.0', | |
'Referer' : 'http://cariresi.com' | |
} | |
payload = { | |
'jasa':jasa, | |
'resi':noresi, | |
'cek' : '' | |
} | |
last_result = '' | |
session = requests.Session() | |
resp = session.post('http://cariresi.com',headers=headers,data=payload) | |
html_element = BeautifulSoup(resp.content,'lxml') | |
resi_detail_element = html_element.find('div', {'class' : 'table table-striped'}) | |
resi_detail_table = resi_detail_element.find('table') | |
resi_table_tr = resi_detail_table.find_all('tr') | |
for element in resi_table_tr: | |
td = element.find_all('td') | |
new_1 = '' | |
for x in td: | |
new_1 += x.text + ' ' | |
# print (new_1) | |
last_result += new_1+'\n' | |
# last_result += '#####'+'\n' | |
resi_journey_table = html_element.find('table',{'id':'tableku'}) | |
resi_journey_tr = resi_journey_table.find_all('tr') | |
for element2 in resi_journey_tr: | |
td2 = element2.find_all('td') | |
new_2 = '' | |
for x2 in td2: | |
new_2 += x2.text+' ' | |
# print (new_2) | |
last_result += new_2+'\n' | |
print last_result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment