質問編集履歴

2

コード全体を記載

2022/01/24 05:08

投稿

momojd2002
momojd2002

スコア3

test CHANGED
File without changes
test CHANGED
@@ -18,31 +18,7 @@
18
18
 
19
19
  ### 記入コード
20
20
  ```ここに言語を入力
21
- from selenium import webdriver
22
- from selenium.common.exceptions import NoSuchElementException
23
- from selenium.webdriver.chrome.options import Options
24
- from time import sleep
25
-
26
- browser = webdriver.Chrome()
27
- URL = 'https://yado.knt.co.jp/yadolist/?use_kbn=1'
28
- browser.get(URL)
29
-
30
- titles = []
31
- prices = []
32
-
33
- while True:
34
- #施設名
35
- elems = browser.find_elements_by_class_name('st2-search-list__title-txt')
36
- for elem in elems:
37
- elem_title = elem.find_element_by_tag_name('span')
38
- title = elem_title.text
39
- titles.append(title)
40
- #価格
21
+ f
41
- elems_p = browser.find_elements_by_class_name('st2-price__price')
42
- for elem_p in elems_p:
43
- elem_price = elem_p.find_element_by_tag_name('span')
44
- price = elem_price.text
45
- prices.append(price)
46
22
  #ページ遷移
47
23
  try:
48
24
  btn = browser.find_element_by_css_selector('div.st2-pagination__item:last-of-type')

1

2022/01/23 17:23

投稿

momojd2002
momojd2002

スコア3

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,31 @@
18
18
 
19
19
  ### 記入コード
20
20
  ```ここに言語を入力
21
+ from selenium import webdriver
22
+ from selenium.common.exceptions import NoSuchElementException
23
+ from selenium.webdriver.chrome.options import Options
24
+ from time import sleep
25
+
26
+ browser = webdriver.Chrome()
27
+ URL = 'https://yado.knt.co.jp/yadolist/?use_kbn=1'
28
+ browser.get(URL)
29
+
30
+ titles = []
31
+ prices = []
32
+
33
+ while True:
34
+ #施設名
35
+ elems = browser.find_elements_by_class_name('st2-search-list__title-txt')
36
+ for elem in elems:
37
+ elem_title = elem.find_element_by_tag_name('span')
38
+ title = elem_title.text
39
+ titles.append(title)
40
+ #価格
41
+ elems_p = browser.find_elements_by_class_name('st2-price__price')
42
+ for elem_p in elems_p:
43
+ elem_price = elem_p.find_element_by_tag_name('span')
44
+ price = elem_price.text
45
+ prices.append(price)
21
46
  #ページ遷移
22
47
  try:
23
48
  btn = browser.find_element_by_css_selector('div.st2-pagination__item:last-of-type')