LoginSignup
2
0

More than 1 year has passed since last update.

Selenium でリンクをたどる (python3)

Last updated at Posted at 2018-03-27

Selenium でリンクをたどるサンプルです。
id と text の例があります。

Arch Linux でのソフトのインストール

sudo pacman -S python-selenium
sudo pacman -S geckodriver
follow_link.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#   follow_link.py
#
#                   May/23/2021
#
# ------------------------------------------------------------------
from selenium.webdriver import Firefox

url = 'https://ekzemplaro.org'

browser = Firefox()
browser.get(url)
tag = browser.find_element_by_id('ekzemplaro')
tag.click()
#
tag = browser.find_element_by_link_text('Tips')
tag.click()
#
# ------------------------------------------------------------------

実行方法

./follow_link.py

実行結果
selenium_may2301.png

テストしたバージョンです。

$ pacman -Q python-selenium
python-selenium 3.141.0-3

$ pacman -Q geckodriver
geckodriver 0.26.0-1
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0