0

I want to extract the variable of a hidden variable from a website like facebook.com. How can i do this using cURL.

Thanks

h4r5h4
  • 403
  • 1
  • 5
  • 12
  • @SabeenMalik $ch = curl_init ("http://www.facebook.com/nike"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $abc = curl_exec ($ch); preg_match("/input type=\"hidden\" name=\"fb_dtsg\" value=\"(.*?)\"/", $abc, $fb_dtsg); – h4r5h4 Jul 05 '12 at 18:05

2 Answers2

1

PLEASE see the first answer to this question. You should NEVER try to use Regex to parse HTML. It doesn't work. Use the PHP Document Object Model to parse the document instead: see this question.

phpQuery is a great tool for what you want to do, and it essentially provides you with the familiar jQuery API within PHP (CSS selectors, etc.)

Community
  • 1
  • 1
Lusitanian
  • 11,012
  • 1
  • 41
  • 38
0

Regular expression:

/<input.+?type=['"]?hidden['"]?.+?value=['"]?(.+?)['"]?/si

I don't know how to make this regexp not depending place of value.

pamil
  • 980
  • 2
  • 10
  • 20