Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why I can't scrape a website?
#8
Hi, metulburr.

Now I learned how to write my scraped-result in Excel, but still can't figure out how to collect only desired information of vr arcades under 'vr' keyword.

I'd like to collect 'title', 'category', 'telephone', 'address' for each item in list or dictionary and print out each set in excel. Please give me any advice.

import os
import sys
import urllib.request
    
client_id = "confidential"
client_secret = "confidential"
url = "https://openapi.naver.com/v1/search/local.json?query=vr&display=3&start=1"
request = urllib.request.Request(url)
request.add_header("X-Naver-Client-Id",client_id)
request.add_header("X-Naver-Client-Secret",client_secret)
response = urllib.request.urlopen(request)
rescode = response.getcode()
if(rescode==200):
    responseBody = response.read().decode('utf-8')
    print(responseBody)
    
    file = open("./vr_arcade.csv", "w+")
    file.write(responseBody)
    
else:
    print("Error Code:" + rescode)
Output:
{ lastBuildDate: "Fri total: 874 start: 1 display: 3 items: [ { title: "arcade1" link: "" category: "category1" description: "" telephone: "telephone" address: "address" roadAddress: "roadAddress" mapx: "310767" mapy: "550356" } { title: "arcade2" link: "https://link2" category: "category2" description: "" telephone: "telephone" address: "address" roadAddress: "roadAddress" mapx: "312508" mapy: "552087" } { title: "arcade3" link: "arcade3.com" category: "arcade" description: "" telephone: "telephone" address: "address" roadAddress: "roadAddress" mapx: "x" mapy: "y" } ] }
Thanks
Reply


Messages In This Thread
why I can't scrape a website? - by kmkim319 - Sep-18-2019, 03:46 PM
RE: why I can't scrape a website? - by metulburr - Sep-18-2019, 06:03 PM
RE: why I can't scrape a website? - by kmkim319 - Sep-20-2019, 06:07 PM
RE: why I can't scrape a website? - by metulburr - Sep-20-2019, 06:38 PM
RE: why I can't scrape a website? - by snippsat - Sep-20-2019, 07:41 PM
RE: why I can't scrape a website? - by kmkim319 - Sep-25-2019, 03:49 AM
RE: why I can't scrape a website? - by metulburr - Sep-25-2019, 11:31 AM
RE: why I can't scrape a website? - by kmkim319 - Sep-27-2019, 03:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to Scrape Website muhamdasim 2 2,562 Dec-27-2021, 07:49 PM
Last Post: JohnRaven
  how to scrape a website from a keyword list greenpine 2 2,326 Dec-04-2020, 03:50 PM
Last Post: greenpine
  scrape data 1 go to next page scrape data 2 and so on alkaline3 6 5,087 Mar-13-2020, 07:59 PM
Last Post: alkaline3
  Read url from CSV and Scrape website Prince_Bhatia 3 10,189 Jan-08-2020, 09:08 AM
Last Post: binaryanimal
  How do i scrape website whose page changes using javsacript _dopostback function and Prince_Bhatia 1 7,158 Aug-06-2018, 09:45 AM
Last Post: wavic
  Scrape A tags from a website Prince_Bhatia 1 4,177 Oct-15-2017, 12:56 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020