1
1
Bifurcation 0

use MSN API instead of screen scraping

Cette révision appartient à :
Anthony Lieuallen 2006-05-19 00:14:34 +00:00
Parent 466a5dcffe
révision 7970888d13

Voir le fichier

@ -132,21 +132,20 @@ var resurrect={
break;
case 'msn':
//FD382E93B5ABC456C5E34C238A906CAB2DEEB5D6
//ugh, they've got an API but .. SOAP? blech too complicated
var searchUrl='http://search.msn.com/results.aspx?q='+encUrl;
var xmlUrl=rawUrl.replace('&', '&');
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 xhr=new XMLHttpRequest();
xhr.open('GET', searchUrl, false);
xhr.send(null);
xhr.open('POST', 'http://soap.search.msn.com/webservices.asmx', false);
xhr.setRequestHeader('Content-Type', 'text/xml; charset=ISO-8859-1');
xhr.setRequestHeader('SOAPAction', '""');
xhr.send(soapBody);
try {
var m=xhr.responseText.match(/<a href=\"([^\"]+)\">Cached page/);
gotoUrl=m[1];
gotoUrl=gotoUrl.replace('&amp;', '&');
} catch (e ) {
gotoUrl=searchUrl;
var c=xhr.responseXML.getElementsByTagName('CacheUrl');
gotoUrl=c[0].textContent;
} catch (e) {
gotoUrl='http://search.msn.com/results.aspx?q='+encUrl;
}
break;