Python Crawling Questions

Asked 2 years ago, Updated 2 years ago, 53 views

url = 'http://openapi.molit.go.kr/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcAptTradeDev?LAWD_CD=11110&DEAL_YMD=201512&serviceKey=nusYWKb7yOPt65dtNy3%2B67YdtP%2FguoXg8iVggMa2uU3toqAYPP2BRRbsuvZPgTrkQIOImy27XWLSXpUYknl3NQ%3D%3D'

from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd

month = 201512
gu_code = 11110
numOfRows = 1000

url = "http://openapi.molit.go.kr/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcAptTradeDev?LAWD_CD="+str(gu_code)+"&DEAL_YMD="+str(month)+"&numOfRows="+str(numOfRows)+"&serviceKey="+str(ServiceKey)

result = urlopen(url) # <http.client.HTTPResponse at 0x1aea5d32f88>
house =  BeautifulSoup(result, 'lxml-xml') # <?xml version="1.0" encoding="utf-8"?>

I keep getting errors if I designate it as house, how do I solve this?

python crawling

2022-09-21 11:33

1 Answers

from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd

month = 201512
gu_code = 11110
numOfRows = 1000
ServiceKey = 'nusYWKb7yOPt65dtNy3%2B67YdtP%2FguoXg8iVggMa2uU3toqAYPP2BRRbsuvZPgTrkQIOImy27XWLSXpUYknl3NQ%3D%3D'

url = "http://openapi.molit.go.kr/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcAptTradeDev?LAWD_CD="+str(gu_code)+"&DEAL_YMD="+str(month)+"&numOfRows="+str(numOfRows)+"&serviceKey="+str(ServiceKey)

result = urlopen(url)
house =  BeautifulSoup(result, 'lxml-xml')

Next time, please write down what kind of error it is.
Looking at the code, I think it's because there's no service key.
It works well when I add it.


2022-09-21 11:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.