Notes
![]() ![]() Notes - notes.io |
import requests
import time
import json
cookies = {
'_pbjs_userid_consent_data': '3524755945110770',
'_sharedID': 'af3ad1e5-e26a-4251-ab6d-39ca5e4cd786',
'__aaxsc': '1',
'__qca': 'P0-1103260322-1668683843260',
'uids': 'eyJ0ZW1wVUlEcyI6eyJhZG54cyI6eyJ1aWQiOiIxMDEwMTIyMDg2MDI0Nzk2Njk5IiwiZXhwaXJlcyI6IjIwMjItMTItMDFUMTE6MTQ6NDYuMzE3NDAzMTM2WiJ9LCJvbmV0YWciOnsidWlkIjoibE42TzFuWWxjcFNnUDR1OGJSMlc3OUpwSGlCTHUzQXRmMWVFZFY1dFNCZyIsImV4cGlyZXMiOiIyMDIyLTEyLTAxVDExOjE0OjQ1LjkyNTUzMjkzNloifSwic292cm4iOnsidWlkIjoiRmM4V3FCWkhLQjdxWTNtaVRaU1kwWUYwIiwiZXhwaXJlcyI6IjIwMjItMTItMDFUMTE6NDE6MDIuMzY0MTQzMDE5WiJ9fSwiYmRheSI6IjIwMjItMTEtMTdUMTE6MTQ6NDUuOTI1NTE3Mjc3WiJ9',
'aasd': '1%7C1669664741031',
'cto_bundle': 'kSapoV9OSFYlMkY0ZmFjVEhBaUNlMjlLcURkOWhLMm03alM5S3ZZRElSVzk1UU9ldVpHbm5zUDR3Ym4lMkZ4WFBYejRZMVBLTE04MXBJMktDT2ZwaGxrTmRsNDBndENtMjMyUGFpRE55MWhrdUpBZjhGN2d6c2RlQ1kwQmtid2RDOE13ekJ2JTJCaFpKS0NUM2Rzb2JZWmVYYnhrY1MyNXclM0QlM0Q',
'cto_bidid': 'fTmNQF9PS2lvRXppWGljZ2xLY3lScGxvT21aamp3WHY4bFV4c0doRHdpeHB0cjlPNzVDbFpacDlEajJrTzVHTmxHUUlCbiUyQm51TGd4b3NRSjhhVDVPRm5pZSUyRnVpa1FwOXJwajRGSDVMdU9RdFdxUVNsb2xXUEo4SnAwQ3lIdW9wZ1RXbGI',
'TADANON': 'TXFKbk9sWWtQd1gweVA4ZjdXaUgzdWJpcnpiZjdQaHp5V042MkgxN0FBb3VKYTlrd3Q4Zzc1TEtGMm1tSGtoSg--',
}
headers = {
'authority': 'www.timeanddate.com',
'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',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'max-age=0',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'cross-site',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
}
cities = [
'adana',
'erzurum',
'canakkale',
'denizli',
'diyarbakir',
'amasya',
'konya',
'ankara',
'eskisehir',
'antalya',
'malatya',
'batman',
'gaziantep',
'mersin',
'bursa',
'istanbul',
'samsun',
'canakkale',
'izmir',
'kahramanmaras',
'trabzon',
'kayseri',
'izmit',
'@295790',
'@295891',
'@295938',
'@295784',
'@295811',
'@295886',
'@295892',
'@295864',
'@295925',
'@295912',
'@295913',
'@295907',
'@295903',
'@295876',
'@295873',
'@295847',
'@295844',
'@295815',
'@295831',
'@295794',
'@295788',
'@295893'
]
url_format_1 = 'https://www.timeanddate.com/weather/turkey/'
url_format_2 = 'https://www.timeanddate.com/weather/'
#to decide and append at the last of format for url parameter in which has @ in the string.
parsed_raw_datas = []
for city in cities:
if '@' in city:
request_url = url_format_2 + city
response = requests.get(url=request_url, cookies=cookies, headers=headers)
else:
request_url = url_format_1 + city
response = requests.get(url=request_url, cookies=cookies, headers=headers)
# print(response.content)
# print(response.text)
if response.status_code == 200:
print('Status_code', response.status_code)
print('REQUEST SENT SUCCESSFULLY:::')
else:
print('Status_code', response.status_code)
print('REQUEST FAILED:::')
print('Request_url', request_url)
dom = html.fromstring(response.content)
name = dom.xpath("//tr/th[text()='Location: ']/following-sibling::td/text()")[0]
print('Pressure:: ', name.strip().split(' ')[0])
degree = dom.xpath("//div[@class='h2']/text()")[0]
print('Degree:: ', degree)
weather = (dom.xpath("(//div[@id='qlook']/p/text())[1]")[0]).replace('.', '')
print('Weather:: ', weather)
feels_like = (dom.xpath("(//div[@id='qlook']/p/text())[2]")[0]).split(': ')[-1]
print('Feels Like::', feels_like)
wind = (dom.xpath("(//div[@id='qlook']/p/text())[3]")[0]).split(': ')[-1]
print('Wind:: ', wind)
humidity = dom.xpath("//tr/th[text()='Humidity: ']/following-sibling::td/text()")[0]
print('Humidity:: ', humidity)
pressure = dom.xpath("//tr/th[text()='Pressure: ']/following-sibling::td/text()")[0]
print('Pressure:: ', pressure)
date = dom.xpath("//tr/th[text()='Current Time: ']/following-sibling::td/text()")[0].split(',')[0]
print('Date:: ', date)
time.sleep(0.5)
print()
print()
# unparsed_json = dom.xpath("//script[@type='application/ld+json']/text()")[0]
#
# parsed_json = json.loads(unparsed_json)
# # print('Parsed_json', parsed_json['itemListElement'][2]['name'].lower())
#
# name = parsed_json['itemListElement'][2]['name'].lower()
# print('Name:: ', name)
# city_mapping = [
# {'@295790': 'Karaman'},
# {'@295891': 'Şanlıurfa'},
# {'@295938': 'Aksaray'},
# {'@295784': 'Erzincan'},
# {'@295811': 'Bitlis'},
# {'@295886': 'Nevşehir'},
# {'@295892': 'Şırnak'},
# {'@295864': 'Muş'},
# {'@295925': 'Adıyaman'},
# {'@295912': 'Çanakkale'},
# {'@295913': 'Balıkesir'},
# {'@295907': 'Manisa'},
# {'@295903': 'Denizli'},
# {'@295876': 'Eskişehir'},
# {'@295873': 'Siirt'},
# {'@295847': 'Uşak'},
# {'@295844': 'Mardin'},
# {'@295815': 'Bingöl'},
# {'@295831': 'Aydın'},
# {'@295794': 'Muğla'},
# {'@295788': 'Elâzığ'},
# {'@295893': 'Kütahya'}]
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team