Needed: Yellow Pages sources

I'm trying to "port" the dashboard yellowpages widget to AveDesk.

The port is going pretty smooth, although I'm now looking for some sources. I'm already using yellowpages.com as a source, but additional ones are also welcome.

If you know other sources for data, and if you preferably can write a javascript parser to extract the relevant data for it , please reply.

We're talking about this widget:

yps.png

See Widget in action (6.3Mb)

#399689

Looks really nice. :)

Here's one link but, they are part of the ypg.com; so, not sure if all of them are actually tied into what you have already.

http://canada411.com/

#399690

Wow, that looks pretty cool :D

#399816

I can tell you that it is a cool widget. I and he's found a few limitations with avescripter that I've fixed while doing this widget :)

All hail the mighty Andreas. :P

#399876

I used to like infospace.com. Have you got an existing JS parser that we can look at and try modifying?

-NC

#400064

http://www.yellowpages.sk/ for slovak users d be appreciated ;)

#400118

NC, here's the parser for yellowpages.com.

/**

* Parser File for Yellow Pages widget.

*

* Public interfaces:

* parser: startSearching(searchText, zip, state);

* widget: deskletServeData(data) with data being an array of tuples(name, address, tel).

*

*

* Flow of events:

* 1) widget calls startSearching(text, zip, state);

* 2) parser starts collecting data

* 3) parser calls deskletServeData(data) when all data has been received

*/





var http = null;

var isBusy = false;





//var baseURL = "http://www.goudengids.nl/list.asp?gonewsrch=1&origin=resultpage&referer=YP&pdf=&exactm=undefined&c=&seed=hosting&wie=&waar=&wat=";

var baseURL = "http://www.yellowpages.com/sp/yellowpages/ypresults.jsp;jsessionid=VS3YHW1J4AYAPQFI4AZRF2Q?t=0&v=3&s=2&st=%STATE%&zp=%ZIP%&_requestid=619491&q=%SEARCH%";



function startSearching(needle, zip, state)

{

http = new ActiveXObject('Microsoft.XMLHTTP');

parser_searchFor(needle, zip, state);

}





var data = null;



function parser_searchFor(needle, zip, state)

{

if(!isBusy)

{

isBusy = true;



var url = baseURL.replace('%ZIP%', zip).replace('%STATE%', state).replace('%SEARCH%',needle);



http.onreadystatechange = parser_onReqDone;

http.open("GET",url,true);

http.send("");

}

}



function parser_onReqDone()

{

if(4 == http.readyState)

{

//var ok = (200 == http.status);



data = new Array();



var txt = http.responseText;

var res = parser_parseRes(txt);

while(res != -1)

{

txt = txt.substr(res, txt.length - res);

res = parser_parseRes(txt);

}



deskletServeData(data);



http = new ActiveXObject('Microsoft.XMLHTTP');

isBusy = false;

}

}





function parser_getValue(txt, start, end)

{

var sindex = txt.indexOf(start);

if(-1 == sindex)

return null;



sindex += start.length;

txt = txt.substr(sindex, txt.length - sindex);



var eindex = txt.indexOf(end);

if(eindex != -1)

{

var val = txt.substr(0, eindex);

return val;

}



return null;

}



function parser_prettyUp(txt)

{

var res = "";

var l = txt.length;

for(var i = 0; i < l; ++i)

{

var c = txt.charAt(i);

if(c != 'n' && c != 'r' && c != 't')

res += c;

}



return res;

}



function parser_parseRes(txt)

{

var itemstart = "<div class="ypListingBox"";

var itemend = "</td>";

var namestart ="target="_blank">";

var namestartB = "target="_blank" style="">";

var nameend = "</a>";

var addressstart = "<div class="ypBAddress">";

var addressend = "</div>";

var telstart ="</div>
";

var telstartB ="target="_blank">";

var telend ="<";



var eindex = 0;

var sindex = txt.indexOf(itemstart);

var ntxt = txt.substr(sindex, txt.length - sindex);

if(sindex != -1)

{

eindex = ntxt.indexOf(itemend);

if(eindex != -1)

{

ntxt = ntxt.substr(0, eindex);



var name = parser_getValue(ntxt, namestartB, nameend);

if(null == name)

name = parser_getValue(ntxt, namestart, nameend);

var address = parser_getValue(ntxt, addressstart, addressend).replace('
', 'n');

var tel = parser_getValue(ntxt, telstart, telend);

if(null == tel || parser_prettyUp(tel).length < 1)

{

tel = parser_getValue(ntxt, telstartB, telend);

}

if(tel != null)

tel = parser_prettyUp(tel);



if(name != null && address != null && tel != null)

data[data.length] = new Array(name, address, tel);

//this.alert(name + ", " + address + "n" + tel);

}

else

{

return -1;

}

}

else

{

return -1;

}



return sindex + eindex;

}

To all: don't expect me to write parsers for all of those.

#400184

To all: don't expect me to write parsers for all of those.

Ah but, you've got sooo much time on your hands, lol. :P

Thx for the parser code. :)

Did you want us to send you the code when we've done it?

#400188

just contact me if you're going to try a parser: I'll send you the widget also.

#400193

NC, here's the parser for yellowpages.com. Blah blah blah blah blah blah blah blah blah blah blah.....

Uhh...:confused:

How 'bout making it like a fill in the blanks thingie.... I have no idea what to do, and I want to help out..

-Ertai

//Edit: I'll try a parser for Canada411 once I figure out things out, and maybe one for Edmonton.

#400194

just contact me if you're going to try a parser: I'll send you the widget also.

Will do. Thanks.

Uhh...:confused:

How 'bout making it like a fill in the blanks thingie.... I have no idea what to do, and I want to help out..

If it only it were that simple.

//Edit: I'll try a parser for Canada411 once I figure out things out, and maybe one for Edmonton.

Umm in an effort to save duplication this is the first one I'm already working on. ;)

It should most likely be general when I'm finished. eg. Business/Category;City;Province;PC1;PC2. :)

#400200

Dibs on infospace...no one else should try that one (again, to prevent duplicatoin).

-NC

#400207

Actually, anyone you send the desklet to, I'll also need to give them the latest avescripter beta, or you can give it to them too.

#400235

Ah, crap, forgat about that. I'll pass them the scripter too then.

#400240

http://www.pagesjaunes.fr

French yellow pages.

Great idea for this, i'm sure it will be a great app (like all your apps)

keep the good work

#402031

http://www.xo.gr

Greek Yellow Pages

#402067

I'm sorry to have to rescind my offer for infospace.com, but I'm simply too busy to work on this. Plus my understanding of the topic isn't exactly first rate.

Sorry :(,

-NC

#402430

here is chinese

http://yp.baidu.com

and here is the javascript from Dashboard's widget

//-------------------------------------------------------//

//Data Exchange

//-------------------------------------------------------//



function sendQuery(term,city,pro){

page=1;

document.getElementById("nextArrow").style.display = 'none';

document.getElementById("prevArrow").style.display = 'none';

term=UrlEncode(term);

startWaitMessage("搜索中");

calculateAndShowThumb(document.getElementById('results'));



baiduUrl="http://yp.baidu.com/m?tn=baiduyp&ct=553648128&rn=20&a=1301&word="+term+"&lm="+pro+"&z="+city;

request=new XMLHttpRequest();

request.onreadystatechange = queryComplete;

request.open("GET",baiduUrl,true);

request.overrideMimeType("text/xml");

request.send(null);



}

function queryComplete(){

//Callback function that's fired when search is complete

calculateAndShowThumb(document.getElementById('results'));

//Query complete callback, start parsing

//stopWaitMessage();

if (request.readyState == 4) {

if (request.status == 200) {

processResult(request.responseText);



}

else {

stopWaitMessage();

displayStatusMessage("There was a problem retrieving the data:n" + req.statusText);

//displayStatusMessage("query failed or unfinished");

}

}

}

#402574