Bonjour,
j ai regardé plusieurs tutoriels permettant de remplir les formulaires mais j ai l impression qu il me manque un truc vu que mes codes ne marchent sur aucuns sites.
Par exemple, ces deux méthodes ne marchent pas sur un site tout simple.
méthode1:
méthode2:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 $postfields = array(); $postfields["RaisonOrIsin"] = "FR0000120271"; $url = "http://www.europafinance.com/europafinance/accueil.jsp"; $useragent = "Mozilla/5.0"; $referer = $url; //Initialise une session CURL $ch = curl_init($url); //CURL options curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); echo $result;
Savez-vous d'où peut venir l'erreur?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 $postfields = array(); $postfields["RaisonOrIsin"] = "FR0000120271"; $url = "http://www.europafinance.com/europafinance/accueil.jsp"; $postdata = http_build_query($postfields); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts ); $result = file_get_contents($url, false, $context); echo $result;
merci pour votre aide.








Répondre avec citation



Partager