i have an issue, i need to learn how to access secure login forms so i can get the data that are inside of them. I am new to this and i want to do it with Curl
and then scrape the data with simple_html_dom
or regex
.As you can see from the code below, it's a simple form username
and password
. My question here is how can i access the form with Curl
and any other form without writing in the page username
admin and password
123? I know that i have to use CURLOPT_RETURNTRANSFER
, CURLOPT_SSL..etc
and i also know that scraping websites it's never the same code, every website has different options that you will have to manage with CURLOPT_...
but i don't know the structure. what i need and where to start.
Code
<body>
<center>
<form method="post">
<label>Username</label>
<input name="user" type="text">
<label>Password</label>
<input name="pass" type="password">
<button type="submit">Submit</button>
</form>
</center>
</body>
<html>
<?php
$name="";
$password = "";
if(!empty($_POST['user']) && !empty($_POST['pass'])){
$name = $_POST['user'];
$password = $_POST['pass'];
}
if($name == "admin" && $password == "123"){
$url = "https://stackoverflow.com/";
$html = file_get_html($url);
foreach ($html->find('a') as $values){
echo $values->href."<br>";
}
} else{
echo "Error";
}
You see this code above: First of all the parsing it's not working inside the if statement
outside it's fine but my issue as i said is how can i access secure forms with curl and then post the scraped data? forms like that are everywhere. if anyone knows how to guide me somewhere or tell would be fine. Thank you for your time