Created
May 6, 2020 23:57
-
-
Save itshaadi/9f524468eb17e1db9c6431deb9092f1e to your computer and use it in GitHub Desktop.
دریافت کارکرد حساب ایرانسل من
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
import requests | |
from lxml import html | |
USERNAME = "<username>" | |
PASSWORD = "<password>" | |
LOGIN_URL = "https://my.irancell.ir/api/verifyecarepass" | |
CSRF_URL = "https://my.irancell.ir/" | |
URL = "https://my.irancell.ir/api/myaccounts_test" | |
def main(): | |
session_requests = requests.session() | |
# Get login csrf token | |
result = session_requests.get(CSRF_URL) | |
tree = html.fromstring(result.text) | |
authenticity_token = list( | |
set(tree.xpath("//input[@name='_csrf']/@value")) | |
)[0] | |
# Create payload | |
payload = { | |
"msisdn": USERNAME, | |
"password": PASSWORD, | |
"_csrf": authenticity_token | |
} | |
# Perform login | |
result = session_requests.post( | |
LOGIN_URL, | |
data=payload, | |
headers=dict(referer=CSRF_URL) | |
) | |
# Scrape url | |
result = session_requests.get(URL, headers=dict(referer=URL)) | |
with open("result.json", "w") as f: | |
f.write(result.content.decode("utf-8")) | |
if __name__ == '__main__': | |
main() |
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
{ | |
"status": 0, | |
"subscriberType": "1", | |
"service": "1", | |
"account": { | |
"productPrivateDas": [ | |
{ | |
"offerID": "52737", | |
"offerName": "ماهانه 110گیگ", | |
"startDateTime": "1399/02/17 00:08", | |
"expiryDateTime": "1399/03/16 23:59", | |
"type": "D", | |
"percentage": 94.4932816245339, | |
"usedValue": "6.05", | |
"usedunit": " گیگابایت ", | |
"offerRemainingValue": "103.94", | |
"remunitNational": " گیگابایت ", | |
"totalValue": "110.00", | |
"remunit": " گیگابایت ", | |
"totunit": " گیگابایت " | |
} | |
], | |
"data": { | |
"used": "6.06", | |
"remaining": "103.94", | |
"percentage": "0.94", | |
"dataRemUnit": " گیگابایت ", | |
"dataUsedUnit": " گیگابایت ", | |
"dataTotalUnit": " گیگابایت ", | |
"peakRemaining": "103.94", | |
"offpeakRemaining": "0.00", | |
"peakRemainingUnit": " گیگابایت ", | |
"offpeakRemainingUnit": " مگابایت " | |
}, | |
"voice": { | |
"used": "0.00", | |
"remaining": "0.00", | |
"totalVoice": "0.00", | |
"percentage": "NaN", | |
"voiceUnit": "دقیقه" | |
}, | |
"sms": { | |
"used": "0.00", | |
"remaining": "0.00", | |
"totalSMS": "0.00", | |
"percentage": "NaN", | |
"smsUnit": "پیامک" | |
}, | |
"nonProductPrivateDas": [], | |
"balance": "0", | |
"tariffPlanName": "TDD طرح تعرفه اعتباري", | |
"tariffPlanCode": "P06055", | |
"activationCode": "1397/04/04" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment