<!-- Need more Alexa data? Find our APIs here: https://aws.amazon.com/alexa/ -->
<ALEXA VER="0.9" URL="lol.com/" HOME="0" AID="=" IDN="lol.com/">
<RLS PREFIX="http://" more="0">
<RL HREF="www.wtf.com/" TITLE="WTF?!"/>
<RL HREF="www.nick.com/" TITLE="Nickelodeon Online"/>
<RL HREF="www.naver.com/" TITLE="네이버"/>
<RL HREF="www.miniclip.com/" TITLE="Miniclip"/>
<RL HREF="www.funnyjunk.com/" TITLE="Funny Junk"/>
<RL HREF="www.1001spill.no/" TITLE="1001 Spill"/>
<RL HREF="rofl.com/" TITLE="ROFL.com Staff Flash"/>
<RL HREF="omg.com/" TITLE="Object Management Group"/>
<RL HREF="lolcom.wordpress.com/" TITLE="LOL.com Development"/>
<RL HREF="chatango.com/" TITLE="Chatango - Add Free Live Chat to any Webpage"/>
</RLS>
<SD TITLE="A" FLAGS="" HOST="lol.com">
<OWNER NAME="ZWave, Llc"/>
</SD>
<SD>
<POPULARITY URL="lol.com/" TEXT="755256" SOURCE="panel"/>
<REACH RANK="662033"/>
<RANK DELTA="+133191"/>
</SD>
</ALEXA>
import xml.etree.ElementTree as et
import requests
url = 'http://data.alexa.com/data?cli=20&dat=snbamz&url=lol.com'
root = et.fromstring(requests.get(url).content)
result = [item.attrib.get('HREF') for item in root.findall('.//RL')]
['www.wtf.com/', 'www.nick.com/', 'www.naver.com/', 'www.miniclip.com/', 'www.funnyjunk.com/', 'www.1001spill.no/', 'rofl.com/', 'omg.com/', 'lolcom.wordpress.com/', 'chatango.com/']
Snake x,y: 371.97999999994363, 308.3599999999333. Fodd x,y: 370, 310
Snake x,y: 371.97999999994363, 308.36999999993327. Fodd x,y: 370, 310
int(snake_pos['x'])
arr1 = {'val1': 1, 'val2': 2, 'val3': 3}
arr2 = {'val1': 6, 'val2': 7, 'val3': 8}
arr3 = {'val1': 9, 'val2': 10, 'val3': 11, 'val4': 12}
something = {
'd': arr1,
'c': arr2,
'a': arr3,
}
default_value = '0000000'
val = 'a'
print(f"Val4: {something.get(val, {}).get('val4', default_value)}")
print(f"Val5: {something.get(val, {}).get('val5', default_value)}")
Val4: 12
Val5: 0000000
Process finished with exit code 0
import pyowm
from pyowm.commons.enums import SubscriptionTypeEnum
from pyowm.utils.measurables import kelvin_to_celsius
city = 'Moscow'
config = {
'subscription_type': SubscriptionTypeEnum.FREE,
'language': 'ru',
'connection': {
'use_ssl': True,
'verify_ssl_certs': True,
'use_proxy': False,
'timeout_secs': 5
},
'proxies': {
'http': 'http://user:pass@host:port',
'https': 'socks5://user:pass@host:port'
}
}
owm = pyowm.OWM('', config=config)
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
print("В городе " + city + " сейчас температура: " + str(kelvin_to_celsius(w.temp['temp'])) + " по Цельсию.")
print('Погода в указанном городе: ' + observation.location.name)
from pip._internal.operations import freeze
x = freeze.freeze()
for p in x:
print(p)
low = 0
high = 4
При экстренном завершении(Нажав на крестик или в диспетчере задач) код не выполняется.
import os
filename = 'save.xlsx'
if os.path.exists(filename):
xlsfile = openpyxl.load_workbook(filename)
else:
xlsfile = openpyxl.Workbook()
max_rows = sheet.max_row
...
sheet['A{}'.format(row + max_rows)].value = data
def sub_main_1():
return 1
def sub_main_2():
return 2
def sub_main_3():
1 / 0
funcs = [sub_main_1, sub_main_2, sub_main_3]
def main():
for func in funcs:
try:
if not func():
return
except Exception as e:
print(e)
return func, False
if __name__ == '__main__':
print(main())
division by zero
(<function sub_main_3 at 0x000002679A31B318>, False)
options.addArguments("profile-directory=Profile 2")
<td class="weather-table__body-cell weather-table__body-cell_type_daypart weather-table__body-cell_wrapper">
<div class="weather-table__wrapper">
<div class="weather-table__daypart">утром</div>
<div class="weather-table__temp">
<div class="temp" role="text"><span class="temp__value">+17</span><span
class="temp__unit i-font i-font_face_yandex-sans-text-medium">°</span>
</div>…<div class="temp" role="text"><span class="temp__value">+22</span><span
class="temp__unit i-font i-font_face_yandex-sans-text-medium">°</span>
</div>
</div>
</div>
</td>
weather_dirt = soup.find_all('span', class_='temp__value')