Created
March 10, 2011 01:32
-
-
Save mizchi/863407 to your computer and use it in GitHub Desktop.
kakaku.com叩く雛形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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