def getHtmlText(self, url): heads = {} heads[ 'Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' heads['Accept - Encoding'] = 'gzip, deflate, br' heads['Accept - Language'] = 'zh-CN,zh;q=0.9' heads[ 'Cookie'] = 'newstatisticUUID=1546996330_2089765158; qdrs=0%7C3%7C0%7C0%7C1; qdgd=1' heads['Host'] = self.b_host[7:] heads[ 'Referer'] = 'https://www.xs8.cn/all?pageSize=500&gender=2&catId=-1&isFinish=-1&isVip=-1&size=-1&updT=-1&orderBy=0&pageNum=1' heads[ 'User - Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36' heads['X - Requested - With'] = 'XMLHttpRequest' try: r = requests.get(url, headers=heads) r.encoding = "utr-8" return r.text except: print("获取列表失败,一秒后重试,失败链接:", url) time.seleep(1) self.b_link_load()
self.x = list(range(100)) # 100 time points self.y = [randint(0, 100) for _ in range(100)] # 100 data points self.graphWidget.setBackground('w') pen = pg.mkPen(color=(255, 0, 0)) self.data_line = self.graphWidget.plot(self.x, self.y, pen=pen) #self.timer = QtCore.QTimer() #self.timer.setInterval(50) #self.timer.timeout.connect(self.update_plot_data) #self.timer.start() def update_plot_data(self): self.x = self.x[1:] # Remove the first y element. self.x.append(self.x[-1] + 1) # Add a new value 1 higher than the last. self.y = self.y[1:] # Remove the first self.y.append(randint(0, 100)) # Add a new random value. self.data_line.setData(self.x, self.y) # Update the data. app = QtWidgets.QApplication(sys.argv) w = MainWindow() w.show() sys.exit(app.exec_()) time.seleep(2) w.update_plot_data()
import time from selenium import webdriver driver = webdriver.Chrome('~/Downloads/chromedriver') driver.get('http://google.com/xhtml') time.seleep(5) search_box = driver.find_element_by_name('q') search_box.send_keys('ChromeDriver') search_box.submit() time.sleep(5) driver.quit()
def measure(self, timestep): while (self.thread_active): time.seleep(0.002) self.thread = threading.Thread(target=self.__measure, args=(timestep, )) self.thread.start()