{"id":16420456,"url":"https://github.com/grindsa/o2_scrap","last_synced_at":"2025-08-22T03:18:35.056Z","repository":{"id":57447485,"uuid":"120874762","full_name":"grindsa/o2_scrap","owner":"grindsa","description":" python library to access the web portal of Telefonica O2 Germany","archived":false,"fork":false,"pushed_at":"2020-10-17T04:49:30.000Z","size":148,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T09:43:45.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grindsa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2018-02-09T07:51:27.000Z","updated_at":"2022-11-09T16:48:46.000Z","dependencies_parsed_at":"2022-09-26T17:30:31.108Z","dependency_job_id":null,"html_url":"https://github.com/grindsa/o2_scrap","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fo2_scrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fo2_scrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fo2_scrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grindsa%2Fo2_scrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grindsa","download_url":"https://codeload.github.com/grindsa/o2_scrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240511299,"owners_count":19813236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T07:28:04.845Z","updated_at":"2025-02-24T16:16:43.980Z","avatar_url":"https://github.com/grindsa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable  MD013 --\u003e\n# o2_scrap\n\n![GitHub release](https://img.shields.io/github/release/grindsa/o2_scrap.svg)\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/grindsa/o2_scrap/master.svg?label=last%20commit%20into%20master)\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/grindsa/o2_scrap/devel.svg?label=last%20commit%20into%20devel)\n\no2_scrap is a python library to access the web portal of Telefonica O2 Germany to fetch\n\n- mobile data-usage of the phone numbers under a specific contract\n- the mobile plan details\n- the last 6 bills\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine.\n\n### Prerequisites\n\nTo run o2_scrap on your system you need\n\n- [Python](https://www.python.org)\n- [Selenium](https://pypi.python.org/pypi/selenium) - Selenium Python Bindigs\n- [geckodriver](https://github.com/mozilla/geckodriver) - Proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers.\n- [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/) - a Python library for pulling data out of HTML and XML files.\n\nPlease make sure python and all the above modules had been installed successfully before you start any kind of testing.\n\n### Installing\n\n#### via Pypi\n\n```bash\n\u003e pip install o2_scrap\n```\n\n#### manually for all users\n\n1. download the archive and unpack it\n2. enter the directory and run the setup script\n\n```bash\n\u003e python setup.py install\n```\n\n#### manually for a single user\n\n1. download the archive and unpack it\n2. move the \"o2_scrap\" subfolder into the directory your script is located\n\n### Usage\n\n#### for mobile contracts\n\nyou need to import o2_scrap into your script\n\n```python\n\u003e from o2_scrap import O2mobile\n```\n\ncreate a new o2_scrap context handler and login to web portal portal to\n\n```python\n\u003e with O2mobile(USER, PASSWORD, DEBUG, HEADLESS) as O2M:\n```\n\n- USER: User-account for o2-online.de\n- PASSWORD: Password for the above user-account\n- DEBUG: True/False - Debug-mode shows more messages and takes screenshots\n- HEADLESS: True/Fals - Turn headless mode on/off (usefull for debugging)\n\nThe method get_numbers() can be used to get the list of mobile numbers under the same contract\n\n```python\n\u003e numbers = O2M.get_numbers()\n```\n\nThe method returns a dictionary containing the mobile numbers and tariff name\n\n```python\n\u003e from pprint import pprint\n\u003e pprint(numbers)\n{u'0176-1234567': u'O2 Blue Data S',\n u'0176-101010101': u'O2 Free M',\n u'0176-87654321': u'O2 Blue Basic',\n u'0176-12312345' Blue All-in L (2015)',\n u'0179-5513345': u'O2 Blue All-in S (2015)'}\n```\n\nTo get the mobile data-usage and further plan details use the get_overview() method\n\n```python\n\u003e data_dict = O2M.get_overview(\u003cmobile-number\u003e)\n```\n\n- mobile-number: phone number to be queried (format must be as obtained via get_numbers() method)\n\nThe method returns a dictionary in the following format\n\n```python\n\u003e from pprint import pprint\n\u003e pprint(data_dict)\n\n{'data-usage': {'autoadjust': u'Datenautomatik deaktiviert',\n                'current': '122 MB',\n                'limit': u'2 GB',\n                'estimation': u'2,35 GB'},\n 'plan-data': {u'K\\xfcndigungsfrist:': u'3 Monat(e) zum Vertragsende',\n               u'Verl\\xe4ngerbar ab:': u'15.12.2017',\n               u'Vertragsbeginn:': u'16.08.2016',\n               u'Vertragsende:': u'15.08.2017',\n               'price': u'19,99 \\u20ac\\nmonatlich',\n               u'sp\\xe4tester K\\xfcndigungstermin:': u'15.05.2018',\n               'tariff': u'O2 Blue All-in S (2015)'}}\n```\n\nTo get the latest bills the method get_bills() must be used.\n\n```python\nbill_list = O2M.get_bills()\n```\n\nThe method returns a list of bills in the following format\n\n```python\n\u003e from pprint import pprint\n\u003e pprint(bill_list)\n\n[{'download': u'https://www.o2online.de/ecare/?0-1.ILinkListener-selfcarePanel-content-contentContainer-content-tabContent-content-mainBills-content-list-0-billDownloadPanel-billDocumentParts-0-downloadLink\u0026intcmp=epo2p_quick-links-teaser_mein-o2-mein-verbrauch',\n  'price': u'23,13€',\n  'text': u'Aktuelle Rechnung vom 03.01.18'},\n {'download': u'https://www.o2online.de/ecare/?0-1.ILinkListener-selfcarePanel-content-contentContainer-content-tabContent-content-mainBills-content-list-1-billDownloadPanel-billDocumentParts-0-downloadLink\u0026intcmp=epo2p_quick-links-teaser_mein-o2-mein-verbrauch',\n  'price': u'56,95€',\n  'text': u'Rechnung vom 03.12.17'},\n {'download': u'https://www.o2online.de/ecare/?0-1.ILinkListener-selfcarePanel-content-contentContainer-content-tabContent-content-mainBills-content-list-2-billDownloadPanel-billDocumentParts-0-downloadLink\u0026intcmp=epo2p_quick-links-teaser_mein-o2-mein-verbrauch',\n  'price': u'45,95€',\n  'text': u'Rechnung vom 03.11.17'},\n {'download': u'https://www.o2online.de/ecare/?0-1.ILinkListener-selfcarePanel-content-contentContainer-content-tabContent-content-mainBills-content-list-3-billDownloadPanel-billDocumentParts-0-downloadLink\u0026intcmp=epo2p_quick-links-teaser_mein-o2-mein-verbrauch',\n  'price': u'23,39€',\n  'text': u'Rechnung vom 04.10.17'},\n {'download': u'https://www.o2online.de/ecare/?0-1.ILinkListener-selfcarePanel-content-contentContainer-content-tabContent-content-mainBills-content-list-4-billDownloadPanel-billDocumentParts-0-downloadLink\u0026intcmp=epo2p_quick-links-teaser_mein-o2-mein-verbrauch',\n  'price': u'67,44€',\n  'text': u'Rechnung vom 05.09.17'}]\n```\n\nto close the browser instance and end the session use the logout() methods\n\n```python\n\u003e O2M.logout(o2b)\n```\n\n#### for DSL contracts\n\ncreate a new context handler and login to web portal portal to\n\n```python\n\u003e with O2dsl(USER, PASSWORD, DEBUG) as O2D:\n```\n\nDSL usage statistics can be obtained by using the get_overview() method\n\n```python\n\u003e data_usage = O2D.get_overview()\n```\n\nthe method will return a dictionary containing\n\n- the actual data usage\n- the monthly limit\n- the prognosed data usage by end of the period\n- the remaining time till period ends\n- a dictionary with the data consumption of the last 6 months\n\n```python\n\u003e from pprint import pprint\n\u003e pprint(data_usage)\n{'history': [{'from': u'15.08.', 'to': u'15.09.', 'usage': 213},\n             {'from': u'15.09.', 'to': u'15.10.', 'usage': 271},\n             {'from': u'15.10.', 'to': u'15.11.', 'usage': 326},\n             {'from': u'15.11.', 'to': u'15.12.', 'usage': 123},\n             {'from': u'15.12.', 'to': u'15.01.', 'usage': 89},\n             {'from': u'15.01.', 'to': u'15.02.', 'usage': 472}],\n 'limit': 300,\n 'prognosed': 169,\n 'remaining': u'Noch 25 Tage im Rechnungsmonat',\n 'since': u'Verbrauchte Daten seit 15.02.2018',\n 'used': 66}\n ```\n\n## Further documentation\n\nPlease check the [doc](https://github.com/grindsa/o2_scrap/tree/master/doc) folder of the project. You will find further documentation and an example scripts of all methods there.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/grindsa/o2_scrap/blob/master/CONTRIBUTING.md) for details on my code of conduct, and the process for submitting pull requests.\nPlease note that I have a life besides programming. Thus, expect a delay in answering.\n\n## Versioning\n\nI use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/grindsa/dkb-robo/tags).\n\n## License\n\nThis project is licensed under the GPLv3 - see the [LICENSE.md](https://github.com/grindsa/o2_scrap/blob/master/LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrindsa%2Fo2_scrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrindsa%2Fo2_scrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrindsa%2Fo2_scrap/lists"}