Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created March 10, 2011 01:32
Show Gist options
  • Select an option

  • Save mizchi/863407 to your computer and use it in GitHub Desktop.

Select an option

Save mizchi/863407 to your computer and use it in GitHub Desktop.
kakaku.com叩く雛形
#!/usr/bin/env python
#-*- encoding:utf-8-*-
import requests
from lxml import etree
base_url = 'http://api.kakaku.com/WebAPI/ItemSearch/Ver1.0/ItemSearch.aspx'
api_key ='<your_api_key>'
def main():
r = requests.get(base_url,
{
"ApiKey":api_key,
"Keyword":"ブルートゥース",
"CategoryGroup":"Pc",
"SortOrder":"popularityrank",
"HitNum":20,
"PageNum":1,
})
dom = etree.fromstring(r.content)
items = dom.xpath("Item")
for i in items:
print i.xpath("ProductID")[0].text
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment