самый простой способ решения
v0 = input('Value 1: ')
v1 = input('Value 2: ')
if (v0 + v1).isdigit():
new_value = str(int(v0) + int(v1))
else:
new_value = v0 + v1
print(v0 + new_value + v1)user_id = id жертвы
profile_pic = session.get(f'https://i.instagram.com/api/v1/users/{user_id}/info/').json()pic_id = int(profile_pic['user']['profile_pic_id'].split('_')[0])alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
def id_to_code(media_id):
shortcode = ''
while media_id > 0:
tail = media_id % 64
media_id = (media_id - tail) // 64
shortcode = alphabet[tail] + shortcode
return shortcode
shortcode = id_to_code(pic_id)import requests
from bs4 import BeautifulSoup
import json
load_url = 'https://www.biz-cen.ru/load/'
search_params = {"metro":{"lines":{}},"was_ra":",","limit":20,"to_ra":0,"tolim":20,"bc_in_fav":[],"office_in_fav":[],"bcs_in_view_start":[],"num_in":3,"typeof_search":5,"show_fav":0}
data = {'search_params':json.dumps(search_params), 'was_bc_loaded':0}
session = requests.Session()
seen = set()
def parse(response):
soup = BeautifulSoup(response.text, 'lxml')
table = soup.find('ul', id='bObjDataList')
if table:
lis = table.find_all('li')
else:
lis = soup.find_all('li')
return [i.find('a').get('href') for i in lis]
while len(seen) < 200:
response = session.post(load_url, data=data)
for link in parse(response):
seen.add(link)
search_params['limit'] += 20
data['search_params'] = json.dumps(search_params)
print(len(seen))Подскажите плиз как распечатать значение tittle= в коде ниже со странички по ссылке?
tag.get('title')import re
from collections import defaultdict
ips = defaultdict(list)
regular = re.compile(r'Host: ([\d\.]+).+?Ports: (\d+)/')
with open('res.txt', 'r') as f:
for line in f:
line = line.strip()
if not line.startswith('#'):
ip, port = regular.search(line).groups()
ips[ip].append(port)
for k, v in ips.items(): # Выведет:
print(k, ', '.join(v)) # 192.168.1.1 80, 801
# 192.168.1.2 801, 445
# 192.168.1.3 80, 8080, 21
with open('outputfile.txt', 'w') as f: # Запишет тоже самое
for k, v in ips.items():
f.write('{} {}\n'.format(k, ', '.join(v))) for y in s:
k = get_url_for_img(y)
print(k)[get_url_for_img(y) for y in s]from itertools import chain можно сделать так:result = list(chain.from_iterable(get_url_for_img(y) for y in s))