{"action":"closed","issue":{"url":"https://api.github.com/repos/artddss/parsing/issues/1","repository_url":"https://api.github.com/repos/artddss/parsing","labels_url":"https://api.github.com/repos/artddss/parsing/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/artddss/parsing/issues/1/comments","events_url":"https://api.github.com/repos/artddss/parsing/issues/1/events","html_url":"https://github.com/artddss/parsing/issues/1","id":168257025,"number":1,"title":"vsemagaziny","user":{"login":"artddss","id":11461272,"avatar_url":"https://avatars.githubusercontent.com/u/11461272?v=3","gravatar_id":"","url":"https://api.github.com/users/artddss","html_url":"https://github.com/artddss","followers_url":"https://api.github.com/users/artddss/followers","following_url":"https://api.github.com/users/artddss/following{/other_user}","gists_url":"https://api.github.com/users/artddss/gists{/gist_id}","starred_url":"https://api.github.com/users/artddss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artddss/subscriptions","organizations_url":"https://api.github.com/users/artddss/orgs","repos_url":"https://api.github.com/users/artddss/repos","events_url":"https://api.github.com/users/artddss/events{/privacy}","received_events_url":"https://api.github.com/users/artddss/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-29T06:05:54Z","updated_at":"2016-07-29T09:34:53Z","closed_at":"2016-07-29T09:34:53Z","body":"```\r\n#!/home/artddss/python3.4/bin/python3.4\r\nfrom urllib.request import urlopen # for Python 3\r\nfrom lxml.etree import XMLSyntaxError\r\nfrom lxml.html import fromstring\r\nfrom pandas import DataFrame, ExcelWriter\r\nimport requests\r\nURL = 'http://www.vsemagazy.ru/'\r\nKATEGORY_PATH = '.menu li '\r\nMAGAZ_PATH = '.tbl-shops tr'\r\nADRES_PATH = '.tbl-shops'\r\nADR_PATH = '.post p b'\r\nSUBJ_PATH = '.post p'\r\ndef vsemagazy_parse():\r\n    f = requests.get('http://www.vsemagazy.ru/')\r\n    list_html = f.text\r\n    list_doc = fromstring(list_html)\r\n    df = DataFrame(columns=('магазин', 'область', 'субъект', 'график работы', 'телефон', 'адрес'))\r\n\r\n    for kategory in list_doc.cssselect(KATEGORY_PATH):\r\n        a = kategory.cssselect('a')[0]\r\n        href = a.get('href')\r\n        name = a.text\r\n \r\n        details_html = requests.get(href).text\r\n        try:\r\n            details_doc = fromstring(details_html)\r\n        except XMLSyntaxError:\r\n             continue\r\n        for magaz in details_doc.cssselect(MAGAZ_PATH):\r\n            b = magaz.cssselect('a')[0]\r\n            zref = b.get('href')\r\n            namb = b.text\r\n            \r\n            drog_html = requests.get(zref).text\r\n            try:\r\n                dret_doc = fromstring(drog_html)\r\n            except XMLSyntaxError:\r\n                continue\r\n\r\n            for adres in dret_doc.cssselect(ADRES_PATH):\r\n                c = adres.cssselect('a')[0]\r\n                nref = c.get('href')\r\n                band = c.text\r\n\r\n                drt_html = requests.get(nref).text\r\n                try:\r\n\r\n                    dry_doc = fromstring(drt_html)\r\n                except XMLSyntaxError:\r\n                    continue\r\n\r\n                subjekt = dry_doc.cssselect(SUBJ_PATH)[0].text_content()\r\n                grafik = dry_doc.cssselect(SUBJ_PATH)[1].text_content()\r\n                telephone = dry_doc.cssselect(SUBJ_PATH)[2].text_content()\r\n                adres = dry_doc.cssselect(SUBJ_PATH)[3].text_content()\r\n                haret_elems_list = [('магазин', name), ('область', namb), ('субъект', subjekt), ('график работы',grafik), ('телефон', telephone), ('адрес', adres)]\r\n                print(haret_elems_list)\r\n                df = df.append(dict(haret_elems_list), ignore_index=True)\r\n    writer = ExcelWriter('magaz.xlsx', engine='xlsxwriter')\r\n    df.to_excel(writer, sheet_name='1', header=True, index=False)\r\n    writer.save()           \r\n\r\ndef main():\r\n    vsemagazy_parse()\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n\r\n```"}}
{"actor":{"display_login":"artddss"}}