質問編集履歴

6

誤字

2018/10/15 02:49

投稿

pokerStars
pokerStars

スコア67

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,15 @@
1
+ ![](b64de48279e38a7ec1bbd0e528ed1445.png)
2
+
3
+
4
+
5
+ このようになり画像が表示できません。
6
+
7
+
8
+
9
+ どのようにすれば画像を表示できますでしょうか?
10
+
11
+
12
+
1
13
  ```Controller
2
14
 
3
15
  def index
@@ -85,15 +97,3 @@
85
97
  <%= @result %>
86
98
 
87
99
  ```
88
-
89
-
90
-
91
- ![イメージ説明](b64de48279e38a7ec1bbd0e528ed1445.png)
92
-
93
-
94
-
95
- このようになり画像が表示できません。
96
-
97
-
98
-
99
- どのようにすれば画像を表示できますでしょうか?

5

誤字

2018/10/15 02:49

投稿

pokerStars
pokerStars

スコア67

test CHANGED
@@ -1 +1 @@
1
- rails selenium 画像を所得したい
1
+ rails selenium 画像をブラウザで表示したい
test CHANGED
@@ -22,13 +22,19 @@
22
22
 
23
23
  @title = params[:title]
24
24
 
25
+
26
+
25
27
  driver.navigate.to 'https://www.justwatch.com/jp/検索?q='+ @title
26
28
 
27
29
  wait = Selenium::WebDriver::Wait.new(timeout: 300)
28
30
 
29
31
  wait.until { driver.find_element(xpath: '//div[2]/filter-bar/div[2]/div[2]/div[3]/div[2]/div') }
30
32
 
31
- el = driver.find_elements(:xpath, '//img[@class="img-responsive poster notransition"]')
33
+
34
+
35
+ el = driver.find_elements(:xpath, '/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[1]/div/div/title-card/track-title-control/div/div[1]/div/div/a/img[2]')
36
+
37
+
32
38
 
33
39
  doc = Nokogiri::HTML.parse(driver.execute_script('return document.documentElement.innerHTML'))
34
40
 
@@ -74,18 +80,20 @@
74
80
 
75
81
 
76
82
 
83
+ <%= @links %>
84
+
77
85
  <%= @result %>
78
86
 
79
87
  ```
80
88
 
81
89
 
82
90
 
83
- ![](07cfa96e4b755c391ec5e0f92473bc3b.png)
91
+ ![イメージ説明](b64de48279e38a7ec1bbd0e528ed1445.png)
84
92
 
85
93
 
86
94
 
87
- このようになり画像が所得できません。
95
+ このようになり画像が表示できません。
88
96
 
89
97
 
90
98
 
91
- どのようにすれば画像が所得できますでしょうか?
99
+ どのようにすれば画像を表示できますでしょうか?

4

誤字

2018/10/15 02:23

投稿

pokerStars
pokerStars

スコア67

test CHANGED
@@ -1 +1 @@
1
- rails selenium 画像とテキスト両方所得したい
1
+ rails selenium 画像所得したい
test CHANGED
@@ -28,6 +28,8 @@
28
28
 
29
29
  wait.until { driver.find_element(xpath: '//div[2]/filter-bar/div[2]/div[2]/div[3]/div[2]/div') }
30
30
 
31
+ el = driver.find_elements(:xpath, '//img[@class="img-responsive poster notransition"]')
32
+
31
33
  doc = Nokogiri::HTML.parse(driver.execute_script('return document.documentElement.innerHTML'))
32
34
 
33
35
 
@@ -39,6 +41,8 @@
39
41
  @result= "結果:" + node.xpath('/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[2]/div[2]/div/div[1]/div/div/div/div/div[2]/div[1]',
40
42
 
41
43
  '/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[2]/div[1]/a').text
44
+
45
+ @links = el.map{|a| a.attribute('src')}
42
46
 
43
47
  end
44
48
 
@@ -76,14 +80,12 @@
76
80
 
77
81
 
78
82
 
79
- 検索をするとテキストは所得できるのですが、画像が所得できません。
83
+ ![](07cfa96e4b755c391ec5e0f92473bc3b.png)
80
84
 
81
85
 
82
86
 
83
- ```
87
+ このようになり画像が所得できません。
84
88
 
85
- @result=
86
89
 
87
- ```
88
90
 
89
- のところがおかしいと思うのですが、どのように変更すれば画像所得できますでしょうか?
91
+ どのようにすれば画像所得できますでしょうか?

3

誤字

2018/10/12 02:11

投稿

pokerStars
pokerStars

スコア67

test CHANGED
@@ -1 +1 @@
1
- rails selenium 何を検索てもターミネーター
1
+ rails selenium 画像とテキスト両方所得たい
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  @title = params[:title]
24
24
 
25
- driver.navigate.to 'https://www.justwatch.com/jp/検索?q=@title&providers=nfx,hlu,dtv,amp,unx'
25
+ driver.navigate.to 'https://www.justwatch.com/jp/検索?q='+ @title
26
26
 
27
27
  wait = Selenium::WebDriver::Wait.new(timeout: 300)
28
28
 
@@ -34,11 +34,15 @@
34
34
 
35
35
  # 検索結果のタイトルを表示
36
36
 
37
- doc.xpath('/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[2]/div[2]/div/div[1]/div/div/div/div/div[2]/div[1]').each do |node|
37
+ doc.xpath('/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]').each do |node|
38
38
 
39
+ @result= "結果:" + node.xpath('/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[2]/div[2]/div/div[1]/div/div/div/div/div[2]/div[1]',
40
+
39
- @result= "結果:" + node.xpath('search-result-entry/div/div[2]/div[1]/a/span[1]').text
41
+ '/html/body/div[2]/filter-bar/ng-transclude/core-list/div/div/div[1]/search-result-entry/div/div[2]/div[1]/a').text
40
42
 
41
43
  end
44
+
45
+ driver.quit
42
46
 
43
47
  end
44
48
 
@@ -72,8 +76,14 @@
72
76
 
73
77
 
74
78
 
75
- 検索フォームウォーキング・デッドと打っているのターミネーター表示され
79
+ 検索をするとテキストは所得るのですが画像所得できせん
76
80
 
77
81
 
78
82
 
83
+ ```
84
+
85
+ @result=
86
+
87
+ ```
88
+
79
- どのようにすればうまくできますでしょうか?
89
+ のところがおかしいと思うのですが、どのように変更すれば画像も所得できますでしょうか?

2

誤字

2018/10/11 04:33

投稿

pokerStars
pokerStars

スコア67

test CHANGED
@@ -1 +1 @@
1
- rails selenium 検索フォムがうまく使えない
1
+ rails selenium 何を検索してもタミネーター
test CHANGED
File without changes

1

誤字

2018/10/11 02:29

投稿

pokerStars
pokerStars

スコア67

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  @title = params[:title]
24
24
 
25
- driver.navigate.to 'https://www.justwatch.com/jp/検索?q=#{@title}&providers=nfx,hlu,dtv,amp,unx'
25
+ driver.navigate.to 'https://www.justwatch.com/jp/検索?q=@title&providers=nfx,hlu,dtv,amp,unx'
26
26
 
27
27
  wait = Selenium::WebDriver::Wait.new(timeout: 300)
28
28
 
@@ -72,9 +72,7 @@
72
72
 
73
73
 
74
74
 
75
- 今このように書いているのですが検索ボンを押すと@resultの部分が表示されるようにるには、どうすればいいでしょうか?
75
+ 検索フォームでウォーキング・デッドと打っているの、ターミネーターが表示され
76
-
77
-
78
76
 
79
77
 
80
78