I need to be able to directly link to images within a lightbox (currently using Lightbox2) from an external website. Basically I want to post a link to one of my images on say, Twitter, and have the link go to my website, open a lightbox, and display the image. I also need to be able to see the image link URL in the address bar while viewing the image in a lightbox. I found this: http://www.huddletogether.com/forum/comments.php?DiscussionID=1407 but it's for an old version of lightbox and for the life of me I couldn't get it work.
Here's a working example:
http://www.rudirakete.de/rudirakete/main#2008-10-5-1526107735
Why not use jQuery dialog().
var p = '<img src="http://www.geekologie.com/2007/12/07/future-car-1.jpg" />';
$('a').click(function() {
$(p).dialog({
minWidth: 500,
buttons: {
OK: function() {
$(this).dialog("destroy");
}
}
})
})
Check working example at http://jsfiddle.net/msKZt/3/
Related
I am using Java and Vaadin to create a simple view where an image is displayed. I have a single Image element containing a source link. Here is my code.
#Route(value = "")
public class MainView extends VerticalLayout {
public MainView() {
add(new Image("https://media.reaperscans.com/file/4SRBHm/comics/14659ab2-5650-4aaf-a5bb-9ad5a9828662/chapters/3aff6399-5ff4-46d1-b502-88788510d962/000.jpg", ""));
}
}
This compiles to a HTML in the browser containing an image element:
<img src="https://media.reaperscans.com/file/4SRBHm/comics/14659ab2-5650-4aaf-a5bb-9ad5a9828662/chapters/3aff6399-5ff4-46d1-b502-88788510d962/000.jpg">
When I open this image in new tab I can see the image correctly, but when I see it in my app there is only:
EDIT:
I can open the image using the link in Google Chrome.
If you open the image on Chrome you will notice the website doesn't allow hotlinking. That's why it doesn't load. Try using a different image (from Wikipedia, for example) and it should work well.
new Image("https://upload.wikimedia.org/wikipedia/commons/8/8e/Vaadin-flow-bakery.png","vaadin");
I recommend using the alt attribute as well, instead of leaving it empty as you had in your original question.
I am trying to web scrape the website savevideo.tube using JSOUP.
When we put a link in the search bar and click the search button, the website dynamically loads and shows some download links that I want to scrape. My problem is how to load link in JSOUP with the link search without clicking the search button and showing the results (scraping the results).
Is there any way to search for a link and load it without clicking any button and get results?
I tried this code but I'm not getting the required result.
val result:Document = Jsoup.connect(Constants.BASE_URL)
.data("url", Constants.YOUTUBE_LINK)
.data("sid", "9823478982349872384789273489238904790234")
.userAgent("Mozilla").post()
JSOUP is a Static HTML parser. You cannot parse the content that is loaded by javascript dynamically. For that, you have to use a web drive.
The best web drives that you can use are
HTML Unit
JBrowserDriver
You can also use selenium but it may not be ideal for android
:-
As mentioned by ʀᴀʜɪʟ, JSOUP is a static HTML parser only. If you want to scrape a website that uses JS generated content you should probably take a look at skrape.it library
fun getDocumentByUrl(urlToScrape: String) = skrape(BrowserFetcher) { // <--- pass BrowserFetcher to include rendered JS
request { url = urlToScrape }
response { htmlDocument { this } }
}
fun main() {
// do stuff with the document
}
I want to extract alt text for all images in web page.
I have tried all the approaches, I know. You can check
below code.
Document doc = Jsoup.connect("https://www.amazon.com/gp/offer-listing/B003FYLW9Q/ref=olp_f_new?ie=UTF8&f_new=true")
.userAgent("Mozilla")
.timeout(50000)
.cookie("cookiename", "val234")
.cookie("anothercookie", "ilovejsoup")
.referrer("http://google.com")
.header("headersecurity", "xyz123")
.get();
// Method 1
Elements images = doc.select("img[src~=(?i)\\.(gif)]");
System.out.println(images.attr("alt"));
// Method 2
String imageAlt = doc.getElementsByClass("a-spacing-none olpSellerName").select("img").attr("alt");
System.out.println(imageAlt);
Now this code does not work for the link right now in connect method.
It does not work for some link and it does not fetch all URLs alt in that webpage.
But this works for below links:
https://www.amazon.com/gp/offer-listing/B06XWZWYVP/ref=olp_f_new?ie=UTF8&f_new=true
https://www.amazon.com/gp/offer-listing/B079JD7F7G/ref=olp_f_new?ie=UTF8&f_new=true
The class is same for all the links. But it does not work for some links. Can any one please tell me the solution for this problem.
I am on this page: http://www.flashscore.com/nhl/. You see here the first table with 'Today's Matches'. If you click on a match, you get to the summary of the game.
There you can click on the 'H2H' tab and you get here: http://www.flashscore.com/match/Q1OevyV9/#h2h;overall. At this point if you open the developer tools, and you click on the network tab you can find out the Request URL.
I started to write a program in JAVA which gets all the Request URLs for all the H2Hs of those matches that are in the 'Today's Matchs' table.
final Document page = Jsoup
.connect("http://d.flashscore.com/x/feed/tx_xlQp8HDC_pMu72He4")
.cookie("_ga","GA1.2.47011772.1485726144")
.referrer("http://d.flashscore.com/x/feed/proxy-local")
.userAgent(myUserAgent)
.header("X-Fsign", "SW9D1eZo")
.header("X-GeoIP", "1")
.header("X-Requested-With", "XMLHttpRequest")
.get();
}
So, with that code I got the page, but I have no idae how to proceed. Can somebody please help me, who has experience in WebScraping?
I need to scrape some details from a website. It loads certain details in Ajax after a button click. Is it is possible to scrape the details from this link?
It loads the details when the + button is pressed.
Yes, you can. Use an ajax callback function and clean the response you receive according to your wishes:
var ajaxurl ='myserver.com/mypage.php';
var ajaxparams = {
do: 'get_my_page',
}
$.post(ajaxurl, ajaxparams, function(response, status){
if (status == 'success')
{
//handle the response her and clean it
}
}
The URL from which the site loads the dynamic content with Ajax is apparently randomly generated, so you will have to scrape it from the HTML of the original page. It can be found in calls to the Javascript function getMusicDetails which is called in the link onclick handlers as follows:
<a onclick="getMusicDetails('0','/md?doc=random_doc_id_here&q=3%20idiots','both');..." />
There doesn't seem to be any session-specific protection of the content, so once you have the ID, it should simply be a matter of issuing a GET to the following URL: http://www.guruji.com/md?doc=random_doc_id_here&q=3%20idiots&rindex=0
(The sample data covers the first plus-link on the page, the other parameters might also vary)