回答編集履歴
3
webdriver.Chrome
test
CHANGED
@@ -130,9 +130,7 @@
|
|
130
130
|
|
131
131
|
# Macの方用のChrome Driverのパスの設定
|
132
132
|
|
133
|
-
|
133
|
+
driver = webdriver.Chrome()
|
134
|
-
|
135
|
-
driver = webdriver.Chrome(ChromeDriverManager().install())
|
136
134
|
|
137
135
|
sleep(1)
|
138
136
|
|
2
微修正
test
CHANGED
@@ -28,9 +28,11 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
|
32
|
+
|
31
33
|
def get_categories():
|
32
34
|
|
33
|
-
categories = []
|
35
|
+
category_items = []
|
34
36
|
|
35
37
|
# Instagramのログインページを指定
|
36
38
|
|
@@ -64,7 +66,7 @@
|
|
64
66
|
|
65
67
|
|
66
68
|
|
67
|
-
categories.append({"link": cat_link, "text": cat_text})
|
69
|
+
category_items.append({"link": cat_link, "text": cat_text})
|
68
70
|
|
69
71
|
|
70
72
|
|
@@ -78,7 +80,9 @@
|
|
78
80
|
|
79
81
|
|
80
82
|
|
81
|
-
return categories
|
83
|
+
return category_items
|
84
|
+
|
85
|
+
|
82
86
|
|
83
87
|
|
84
88
|
|
@@ -94,13 +98,13 @@
|
|
94
98
|
|
95
99
|
i = 1
|
96
100
|
|
97
|
-
recipe_page
|
101
|
+
recipe_page = driver.find_elements_by_xpath('//*[@id="popularityList"]/ul/li')
|
98
102
|
|
99
103
|
# レシピのリンクを取得
|
100
104
|
|
101
|
-
for recipe in recipe_page
|
105
|
+
for recipe_html in recipe_page:
|
102
106
|
|
103
|
-
url = recipe.find_element_by_xpath(
|
107
|
+
url = recipe_html.find_element_by_xpath(
|
104
108
|
|
105
109
|
'div[@class="texts"]/div[1]/a').get_attribute('href')
|
106
110
|
|
@@ -158,4 +162,6 @@
|
|
158
162
|
|
159
163
|
driver.close()
|
160
164
|
|
165
|
+
|
166
|
+
|
161
167
|
```
|
1
変数が重複していたので修正
test
CHANGED
@@ -82,8 +82,6 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
|
86
|
-
|
87
85
|
def get_recipe(category, driver):
|
88
86
|
|
89
87
|
recipe_items = []
|
@@ -96,11 +94,11 @@
|
|
96
94
|
|
97
95
|
i = 1
|
98
96
|
|
99
|
-
recipes = driver.find_elements_by_xpath('//*[@id="popularityList"]/ul/li')
|
97
|
+
recipe_pages = driver.find_elements_by_xpath('//*[@id="popularityList"]/ul/li')
|
100
98
|
|
101
99
|
# レシピのリンクを取得
|
102
100
|
|
103
|
-
for recipe in recipes:
|
101
|
+
for recipe in recipe_pages:
|
104
102
|
|
105
103
|
url = recipe.find_element_by_xpath(
|
106
104
|
|