Reputation: 81
I know this post may Duplicate from other questions,but i have read any post and do not get what i want to know
I have read this Post before i ask this.
I want to scrape This page with BeautifulSoup
and requests.post
to submit some form from web.
And this example code i used:
import requests, json
from bs4 import BeautifulSoup as BS
url = "https://www.resi.co.id"
datas = {
"userForm":{
"id":"80879880999985"
}
}
with requests.Session() as s:
req = s.post(url, data=json.dumps(datas)
if req.ok:
soups = BS(req.text,"html.parser")
print(soups.prettify())
I think i can see output what i want,but no one results i want from output,Where my wrong? I just read and try any examples from google and post from stackoverflow but i didn't getting anything what i want.
I really appreciate every help, and sorry for my English.
Upvotes: 0
Views: 47
Reputation: 28565
Not quite entirely sure what you want as it's not clear. But, to get the data, you need to include those in your datas
. Also the request url is https://api1.cekresi.co.id/allcnote.php
. It'll return html/text, not json. And then you can use pandas to just grab those tables:
import requests
import pandas as pd
from bs4 import BeautifulSoup as BS
url = "https://api1.cekresi.co.id/allcnote.php"
datas = {"id":"070950000307119",
'kurir': 'jne'}
with requests.Session() as s:
req = s.post(url, data=datas)
if req.ok:
tables = pd.read_html(req.text)
for table in tables:
print (table)
print ('\n')
Output:
0 1 2
0 No Resi : 070950000307119
1 Status : DELIVERED
2 Service : YES19
3 Dikirim tanggal : 2019-02-09
4 Dikirim oleh : JESAND SHOPBEKASI
5 Dikirim ke : EDWINPINANG , TANGERANG
6 JNE Status : DELIVERED
0 ... 2
0 Tanggal ... Keterangan
1 2019-02-09 14:07 ... SHIPMENT RECEIVED BY JNE COUNTER OFFICER AT [B...
2 2019-02-09 17:08 ... SHIPMENT PICKED UP BY JNE COURIER [BEKASI]
3 2019-02-09 17:14 ... RECEIVED AT SORTING CENTER [BEKASI]
4 2019-02-09 19:46 ... PROCESSED AT SORTING CENTER [BEKASI]
5 2019-02-10 03:50 ... RECEIVED AT WAREHOUSE [TANGERANG]
6 2019-02-10 05:33 ... SHIPMENT FORWARDED TO DESTINATION [TANGERANG, ...
7 2019-02-10 12:42 ... RUMAH / KANTOR KOSONG
8 2019-02-10 12:42 ... WITH DELIVERY COURIER [TANGERANG]
9 2019-02-11 10:32 ... WITH DELIVERY COURIER [TANGERANG]
10 2019-02-11 13:40 ... ALAMAT TIDAK LENGKAP / TIDAK D
11 2019-02-11 15:10 ... WITH DELIVERY COURIER [TANGERANG]
12 2019-02-11 15:32 ... DELIVERED TO [EDWIN | 11-02-2019 15:32 | TANGE...
[13 rows x 3 columns]
0 1 2
0 Tanggal Lokasi Keterangan
1 2019-02-09 PINANG , TANGERANG DELIVERED
Upvotes: 1