sandeep03edu

ISRO

Jan 20th, 2023 (edited)
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.32 KB | None | 0 0
  1. # import requests
  2. import os
  3. from urllib.parse import parse_qsl, urljoin, urlparse
  4. loginurl='https://idp.issdc.gov.in/auth/realms/issdc/protocol/openid-connect/auth?response_type=code&client_id=Pradan&redirect_uri=https%3A%2F%2Fpradan.issdc.gov.in%2Fch2%2Fprotected%2Fbrowse.xhtml?id%3Dtmc2&state=bb4349bc-2156-4896-b915-9c64f0209ba8&login=true&scope=openid'
  5. # theurl= 'https://pradan.issdc.gov.in/ch2/protected/downloadData/POST_OD/isda_archive/ch2_bundle/cho_bundle/nop/ohr_collection/data/calibrated/20220129/ch2_ohr_ncp_20220129T0150171705_d_img_d18.zip'
  6. username = 'IITP_MID'
  7. password = 'Iitisro@'
  8. import requests
  9. from requests.auth import HTTPBasicAuth
  10. from bs4 import BeautifulSoup
  11.  
  12. login_url = loginurl
  13. data = {
  14.     'username': 'IITP_MID',
  15.     'password': 'Iitisro@'
  16. }
  17.  
  18. # with requests.Session() as s:
  19.  
  20. cookies = {
  21.     'JSESSIONID': '074bc21e370439db8131a256ac0c',
  22.     'OAuth_Token_Request_State': '607c02d1-3279-41b3-9d72-1668b89b1599',
  23. }
  24.  
  25. headers = {
  26.     'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  27.     'Accept-Language': 'en-US,en;q=0.9',
  28.     'Cache-Control': 'max-age=0',
  29.     'Connection': 'keep-alive',
  30.     # 'Cookie': 'JSESSIONID=074bc21e370439db8131a256ac0c; OAuth_Token_Request_State=607c02d1-3279-41b3-9d72-1668b89b1599',
  31.     'Sec-Fetch-Dest': 'document',
  32.     'Sec-Fetch-Mode': 'navigate',
  33.     'Sec-Fetch-Site': 'same-site',
  34.     'Sec-Fetch-User': '?1',
  35.     'Upgrade-Insecure-Requests': '1',
  36.     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
  37.     'sec-ch-ua': '"Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109"',
  38.     'sec-ch-ua-mobile': '?0',
  39.     'sec-ch-ua-platform': '"Windows"',
  40. }
  41.  
  42. response = requests.get('https://pradan.issdc.gov.in/ch2/protected/browse.xhtml?id=tmc2', cookies=cookies, headers=headers)
  43.  
  44. # print(response.text)
  45. soup=BeautifulSoup(response.content,"html.parser")
  46.  
  47. element_by_id=soup.find("tbody",{"id":"tableForm:lazyDocTable_data"})
  48.  
  49. print(element_by_id)
  50.  
  51. download = "";
  52. for a in element_by_id.find_all('a', href=True):
  53.   print("Found the URL:", a['href'])
  54.   download = a['href']
  55.  
  56. download = "https://pradan.issdc.gov.in" + download
  57.  
  58. print("Downloading: " + download)
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment