Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

         $iframe.contents().find('.result-row').each(function(){
         data.push({
                         title: $(this).find('.result-title').text(),
                         img: $(this).find('img').attr("src"),
                         price: $(this).find('.result-price:first').text()
             });
         // And everything starts running when you set first iframe's target url
         $iframe.prop("src", "https://newyork.craigslist.org/d/apts-housing-for-rent/search/apa");

Looks like he wants output something like

         title: 
         img:
         price:
I tried reproducing this example without using Javascript, instead using curl and sed. The output is

         image: 
         title:
         price
I did not try to move "title:" above "image:" though I bet this could be done using the hold space. Nor did I format this as JSON though that would be easy to do.

         n=0;while true;do test $n -le 3000||break;
         curl https://newyork.craigslist.org/d/apts-housing-for-rent/search/apa?s=$n|sed -n '
         /result-title hdrlnk/{s/.*\">/title: /;s/<.*//;/^title: /p;};
         /./{/result-meta/,/\/span/{/result-price/s/.*\">/price: /;s/<.*//;/price/p;};};
         /data-ids=\"/{s|1:[^,\">]*|https://images.craigslist.org/&_600x450.jpg|g;s/,/, /g;
         s/1://g;s/>//;s/.*data-ids=/image: /;/^image: /p;}'
         n=$((n+120));done


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: