简体   繁体   中英

Where to put piece of code

I found a script which makes it possible to screen scrape a website, example: JsFiddle

The problem is that I want to include another script from "Embed.ly" This script allows to "enrich" a given link. The code for this is very simple:

  $('div.content').embedly({key: 41f042ec20b04dda84448dc4a46d357d}); 

However I can't seem to give it an appropriate place within the script. It doesn't work wherever I put it, but even worse the screen scraping script also stops working. So where in the script should I put my embedly code??

It's mainly the cross origin script...

http://jsfiddle.net/Vandeplas/m4QCt/103/

I commented out the find links part because the response of the jquery.xdomainajax.js lib is returning jibbrish... (It seems to work half of the time!?)

Minor details: you're api key needs quotes around it, the url needs to be in the href part to make the embedly work, you need to select '.content' to append the links to and you don't need the $('.content') just the selector is fine as parameter for append. (both will work ;) )

You can write your own proxy script for dealing with the cross origin issues... A proxy script is a sort of middleware. You make a request to the script the script gets the data, and returns it to you. For example php proxy . You can make the same thing in asp, jsp, flash or even java applet.

EDIT:

response I was getting half of the time...

吉布利什

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM