I'd like to parse the homepage in the form of json and post with Python.

Asked 2 years ago, Updated 2 years ago, 106 views

I'd like to parse the course guide page on the school website with Python. The url of the source code is not the URL https://e-onestop.pusan.ac.kr/menu/class/C03/C03001?menuId=2000030301&rMenu=03, but the request url from the network item in Chrome's F12 developer mode when you press the 'search' button.

import urllib2
import json
import urllib
import requests
from BeautifulSoup import BeautifulSoup
url = "https://e-onestop.pusan.ac.kr/middleware/curriculum/college/CollegeAssignInfoSearch"
payload = {
    'pName': ['YEAR', 'TERM', 'DEPTCD', 'CULTCD', 'GUBUN'],
    'pValue': ['2017', '10', '480000', '', '1']
}
response = requests.post(url, params=payload)

print response.text

I tested it as the default post method for imported libraries, but when I pressed the search button, there was no added or changed part in the parsed HTML source code. I wrote here because I don't know what's missing because I don't think I'm going to do normal movements because I can't get only the fluid parts.

If there is anyone who can help me, I appreciate the small things, so please reply.

python json post

2022-09-21 15:16

1 Answers

If you're talking about this search result, I think it's a problem that can be solved by changing url.

# console: POST XHR
mainurl = "https://e-onestop.pusan.ac.kr/menu/class/C03/C03001?menuId=2000030301&rMenu=03"
suburl = "/middleware/curriculum/college/CollegeAssignInfoSearch"


url = mainurl+suburl

payload = {
    'pName': ['YEAR', 'TERM', 'DEPTCD', 'CULTCD', 'GUBUN'],
    'pValue': ['2017', '10', '11665', '', '5']
}
response = requests.post(url, params=payload)

print response.text

mainurl is the undergraduate course guide url, and the post location is suburl. payload was sent to the combined address of the two. I am a Firefox user, so I found out url or payload by looking at the console in the developer tool.


2022-09-21 15:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.