use MSN API instead of screen scraping
Cette révision appartient à :
Parent
466a5dcffe
révision
7970888d13
1 fichiers modifiés avec 10 ajouts et 11 suppressions
|
@ -132,21 +132,20 @@ var resurrect={
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'msn':
|
case 'msn':
|
||||||
//FD382E93B5ABC456C5E34C238A906CAB2DEEB5D6
|
var xmlUrl=rawUrl.replace('&', '&');
|
||||||
//ugh, they've got an API but .. SOAP? blech too complicated
|
var soapBody='<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"><SOAP-ENV:Body><ns1:Search xmlns:ns1="http://testuri.org"><Request><AppID xsi:type="xsd:string">FD382E93B5ABC456C5E34C238A906CAB2DEEB5D6</AppID><Query xsi:type="xsd:string">'+xmlUrl+'</Query><CultureInfo xsi:type="xsd:string">en-US</CultureInfo><SafeSearch xsi:type="xsd:string">Off</SafeSearch><Requests><SourceRequest><Source xsi:type="xsd:string">Web</Source><Offset xsi:type="xsd:int">0</Offset><Count xsi:type="xsd:int">1</Count><ResultFields xsi:type="xsd:string">All</ResultFields></SourceRequest></Requests></Request></ns1:Search></SOAP-ENV:Body></SOAP-ENV:Envelope>';
|
||||||
|
|
||||||
var searchUrl='http://search.msn.com/results.aspx?q='+encUrl;
|
|
||||||
|
|
||||||
var xhr=new XMLHttpRequest();
|
var xhr=new XMLHttpRequest();
|
||||||
xhr.open('GET', searchUrl, false);
|
xhr.open('POST', 'http://soap.search.msn.com/webservices.asmx', false);
|
||||||
xhr.send(null);
|
xhr.setRequestHeader('Content-Type', 'text/xml; charset=ISO-8859-1');
|
||||||
|
xhr.setRequestHeader('SOAPAction', '""');
|
||||||
|
xhr.send(soapBody);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var m=xhr.responseText.match(/<a href=\"([^\"]+)\">Cached page/);
|
var c=xhr.responseXML.getElementsByTagName('CacheUrl');
|
||||||
gotoUrl=m[1];
|
gotoUrl=c[0].textContent;
|
||||||
gotoUrl=gotoUrl.replace('&', '&');
|
} catch (e) {
|
||||||
} catch (e ) {
|
gotoUrl='http://search.msn.com/results.aspx?q='+encUrl;
|
||||||
gotoUrl=searchUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Chargement…
Référencer dans un nouveau ticket