回答編集履歴

1

add sample code

2020/09/09 08:24

投稿

necocoa
necocoa

スコア209

test CHANGED
@@ -3,3 +3,27 @@
3
3
  ](https://stackoverflow.com/questions/2986252/ruby-can-net-http-make-a-get-and-post-request-simultaneously)
4
4
 
5
5
  こちらでheaderオプションの渡し方が書いてあるため、'Referer'の部分を該当のドメインに変更して試してみたらできそうです!
6
+
7
+
8
+
9
+ ```ruby
10
+
11
+ uri = URI.parse('target_uri')
12
+
13
+
14
+
15
+ http = Net::HTTP.new(uri.hostname, uri.port)
16
+
17
+ req = Net::HTTP::Get.new(uri.request_uri, { 'Referer' => 'http://www.example.com/' })
18
+
19
+ response = http.request(req)
20
+
21
+
22
+
23
+ response.body
24
+
25
+ ```
26
+
27
+
28
+
29
+ こんな形で試してみてください!