HttpParty代理IP地址使用情况

时间:2016-07-16 14:46:59

标签: ruby-on-rails ruby httparty open-uri

所以我打电话给api,看起来像这样(为安全yada yada删除了网址)

<?php

    if(isset($_POST['Submit'])){



        $FName= $_POST['First_name'];
        $LName = $_POST['Last_name'];
        $Email = $_POST['Email'];
        $PW = $_POST['Password'];

        $sql = mysql_query("INSERT INTO users VALUES('', {$FName}','{$LName}','{$Email}','{$PW}')", $con);

        if(isset($_POST['First_name'])){$FName = $_POST['First_name'];}

    }

?>

<!DOCTYPE html>
<html>
<head>
    <title>Register</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" type="text/css" href="menu.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="index.jpg" style="width: 20%;height: 65px; align: center;">   
        </div>
        <div class="menu" id="menu">
            <nav>
                <ul class="cssmenu">
                    <li><a href="#">Register</a></li>
                    <li><a href="#">Log In</a></li>
                </ul>
            </nav>
        </div>
        <div class="leftbody">
            <img src="index.jpg">
        </div>
        <div class="rightbody">
            <form action="register.php" method="POST" id="registerform">
                <div class="Formelement">
                    <input type="text" name="First_name" class="tfield" required="required" placeholder="First_Name">
                </div><br>

                <div class="Formelement">
                     <input type="text" name="Last_name" class="tfield" required="required" placeholder="Last_Name">
                </div><br>

                <div class="Formelement">
                    <input type="text" name="Email" class="tfield" required="required" placeholder="Email">
                </div><br>

                <div class="Formelement">
                     <input type="password" name="Password" class="tfield" required="required" placeholder="Password">
                </div><br>

                <input type="submit" name="Submit" value="Register">
            </form>
        </div>
        <div class="footer"></div
        >
    </div>
</body>
</html>

现在我想要的是使用我的代理IP地址来访问网页。你愿意指出我正确的方向吗?

我已经知道如何在open-uri中执行此操作,但不确定是否可以使用此gem来获取请求。

由于 萨姆

1 个答案:

答案 0 :(得分:1)

这应该有用。

apicall = HTTParty.get(
  'URL HERE',
  http_proxyaddr:'PROXY IP HERE',
  http_proxyport: 'PROXY PORT HERE',
  http_proxyuser: 'PROXY USERNAME HERE',
  http_proxypass: 'PROXY PASSWORD HERE',
  headers: {"Authorization" => "Bearer apikey"}
).parsed_response

跳过您没有值的http_proxy****个键。您可以在此处找到更好地了解您可以在HTTParty中实施的内容所需的一切:HTTParty Github