I am not sure whether this is possible or not, but if it is, I need to know where to start at least. I want to fill the form on the site I do not own, using a field on the site I do own.
我不确定这是否可能,但如果是的话,我至少需要知道从哪里开始。我想在我不拥有的网站上填写表格,使用我拥有的网站上的一个字段。
Specifically this computer game site http://www.g2a.com/, and the search form there which is
具体来说,这个电脑游戏网站http://www.g2a.com/,以及那里的搜索表单
<input type="text" class="mp-h-main ui-autocomplete-input" id="product-autocomplete" placeholder="Search a game" data-rel="active" autocomplete="off" state="closed">
It seems to be Ajax or jQuery loaded, and there seems to be no regular search function on the site. Is there a good known way, or do I stand little chance in this case?
它似乎是Ajax或jQuery加载的,在站点上似乎没有常规的搜索功能。是否有一个众所周知的方法,或者我在这种情况下几乎没有机会?
Kind regards, John
亲切的问候,约翰
1 个解决方案
#1
3
Sniff the form post content using something like live http headers for firefox and emulate it with php curl, i.e.:
使用firefox的live http header来嗅探表单post内容,并使用php curl来模拟它,例如:
<?php
$productName = rawurlencode("DOOM STEAM CD-KEY PREORDER GLOBAL");
$url = "https://www.g2a.com/lucene/search/quick?jsoncallback=jQuery111005943281338131983_1462669099509&phrase=$productName&isWholesale=false&cn=&skip=28837%2C28838%2C28847%2C28849%2C28852%2C28856%2C28857%2C28858%2C28859%2C28860%2C28861%2C28862%2C28863%2C28867%2C28868%2C29472%2C29473%2C29474%2C33104&start=0&rows=5&_=1462669099513";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Host: www.g2a.com",
"Accept: text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01",
"Accept-Language: en-US,en;q=0.5",
"Accept-Encoding: gzip, deflate, br",
"X-Requested-With: XMLHttpRequest",
"Referer: https://www.g2a.com/",
"Cookie: store=englishus; user_time_offset=-120; _ga=GA1.2.1616293500.1462668986; PHPSESSID=eemnk12t6fml8l0l0mf3l63tr5; currency=USD; _gat=1; __ar_v4=WZC2HGDHXZBR7NN565K5H7%3A20160507%3A3%7CY5G5B7MZYJA65OM2BVC43V%3A20160507%3A3%7CJOM3QZF4VBESRIYVTRCJ3R%3A20160507%3A3; Hm_lvt_11391e2f2164ca5838ee836fac473f57=1462668991,1462669101; Hm_lpvt_11391e2f2164ca5838ee836fac473f57=1462669101; external_no_cache=1",
"Connection: keep-alive"
));
$response = curl_exec($ch);
echo $response;
curl_close ($ch);
Output:
输出:
jQuery111005943281338131983_1462669099509({"numFound":1,"start":0,"docs":[{"id":27581,"name":"DOOM STEAM CD-KEY PREORDER GLOBAL","type":"egoods","preOrder":1,"slug":"/doom-steam-cd-key-preorder-global.html","addUrl":"uenc/aHR0cDovLw,,/product/27581/","minPrice":32.99,"g2aQty":1,"g2aPrice":32.99,"retailQty":0,"wholesaleQty":0,"thumbnail":"https://images.g2a.com/m/58x58/1x1x1/thumbnail/d/o/ef1f8c916783_doom_2d_3.png","brandsDirectOnSearch":0,"bdPrice":0}]})
#1
3
Sniff the form post content using something like live http headers for firefox and emulate it with php curl, i.e.:
使用firefox的live http header来嗅探表单post内容,并使用php curl来模拟它,例如:
<?php
$productName = rawurlencode("DOOM STEAM CD-KEY PREORDER GLOBAL");
$url = "https://www.g2a.com/lucene/search/quick?jsoncallback=jQuery111005943281338131983_1462669099509&phrase=$productName&isWholesale=false&cn=&skip=28837%2C28838%2C28847%2C28849%2C28852%2C28856%2C28857%2C28858%2C28859%2C28860%2C28861%2C28862%2C28863%2C28867%2C28868%2C29472%2C29473%2C29474%2C33104&start=0&rows=5&_=1462669099513";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Host: www.g2a.com",
"Accept: text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01",
"Accept-Language: en-US,en;q=0.5",
"Accept-Encoding: gzip, deflate, br",
"X-Requested-With: XMLHttpRequest",
"Referer: https://www.g2a.com/",
"Cookie: store=englishus; user_time_offset=-120; _ga=GA1.2.1616293500.1462668986; PHPSESSID=eemnk12t6fml8l0l0mf3l63tr5; currency=USD; _gat=1; __ar_v4=WZC2HGDHXZBR7NN565K5H7%3A20160507%3A3%7CY5G5B7MZYJA65OM2BVC43V%3A20160507%3A3%7CJOM3QZF4VBESRIYVTRCJ3R%3A20160507%3A3; Hm_lvt_11391e2f2164ca5838ee836fac473f57=1462668991,1462669101; Hm_lpvt_11391e2f2164ca5838ee836fac473f57=1462669101; external_no_cache=1",
"Connection: keep-alive"
));
$response = curl_exec($ch);
echo $response;
curl_close ($ch);
Output:
输出:
jQuery111005943281338131983_1462669099509({"numFound":1,"start":0,"docs":[{"id":27581,"name":"DOOM STEAM CD-KEY PREORDER GLOBAL","type":"egoods","preOrder":1,"slug":"/doom-steam-cd-key-preorder-global.html","addUrl":"uenc/aHR0cDovLw,,/product/27581/","minPrice":32.99,"g2aQty":1,"g2aPrice":32.99,"retailQty":0,"wholesaleQty":0,"thumbnail":"https://images.g2a.com/m/58x58/1x1x1/thumbnail/d/o/ef1f8c916783_doom_2d_3.png","brandsDirectOnSearch":0,"bdPrice":0}]})