スキップしてメイン コンテンツに移動

raspiでseleniumの自動化用のファイル作り直し

2024/2/17に不注意でraspiのsdカードを壊し

jupyterファイルのバックアップを取らずにos再インストールを試みるという

愚行を重ねたためまたjupyterで作業ファイルを作ることになったので念の為

残しておく

途中なので要らない行も有るかも

これだけ再現できればやってたことは出来るのでよき



from selenium import webdriver

from selenium.webdriver import Chrome, ChromeOptions

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.action_chains import ActionChains

from selenium.webdriver.common.by import By

from selenium.webdriver.chrome.service import Service 

import time


options1=ChromeOptions()

extension_path ='/home/pi/selenium1/Mouse-Coordinates.crx'

options1.add_extension(extension_path)

path1 = '/usr/bin/chromedriver'

driver1=Chrome(service=Service(path1),options=options1)


url1 = 'https://www.google.co.jp/'

driver1.get( url1 ) 

actions=ActionChains(driver1)


def pointclick(px,py):

  actions.move_by_offset(px,py).click().perform()

  actions.move_by_offset(-px,-py).click().perform()


serch_input=driver1.find_element(By.NAME,"q")

serch_input.send_keys('chatgpt')


pointclick(158,203)

time.sleep(2)

pointclick(405,272)




コメント

このブログの人気の投稿

Arduino IDE が "Downloading index: library_index.tar.bz2" で固まる問題

PCとのシリアル通信が原因の一つらしい '/home/usename/.arduino15/packages' を消すといいらしい ので消すと治った IDEの起動中にフリーズしてたのが治った Downloading index: library_index.tar.bz2 とダウンロード中だったが終了したので起動中のフリーズが起こるようになった

Blogger でp5jsがつかえた

”HTMLビュー”でHTMLを編集  divとcanvasを関連付ければ良いみたい (div id="p5canvas とcreateCanvasの.parent("p5canvas");) p5js本体はCDNを参照(https://cdnjs.com/libraries/p5.js) コードはP5サイトのEXAMPLEから(https://p5js.org/examples/3d-geometries.html) <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script> <div id="p5canvas"></div> <script> function setup() { createCanvas(710, 400, WEBGL).parent("p5canvas"); } function draw() { background(250); translate(-240, -100, 0); normalMaterial(); push(); rotateZ(frameCount * 0.01); rotateX(frameCount * 0.01); rotateY(frameCount * 0.01); plane(70); pop(); translate(240, 0, 0); push(); rotateZ(frameCount * 0.01); rotateX(frameCount * 0.01); rotateY(frameCount * 0.01); box(70, 70, 70); pop(); translate(240, 0, 0); push(); rotateZ(frameCount * 0.01); rotateX(frameCount * 0.01); rotateY(frameCount * 0.01); cylinder(70, 70); pop(); ...

クラスカル法

chat-gptにきいたらおしえてくれた                                                                参考動画 <!DOCTYPE html> <html lang="en"> <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script> <div id="p5canvas"></div> <script> class Graph {   constructor() {     this.vertices = [];     this.edges = [];   }   addVertex(x, y) {     this.vertices.push({ x, y });   }   addEdge(source, destination, weight) {     if (this.vertices[source] && this.vertices[destination]) ...