I try to load Twitter into my UIWebView Using loadHTMLString (after loading the DOM using an NSURLRequest), now the string I have contains the correct HTML.
It loads the twitter page, but then I only get the black bar showing a progress circle, is anyone familiar with this problem and knows how to solve it?
Why do you download the html first and try loading the UIWebView with loadHTMLString after?
I think you create some issue with the ajax 'magic' because you don't run the html from the same domain as your ajax calls. And it seems like cross site scripting.
I think you can better use something like this and really load in the twitter homepage.
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
Related
I am unable to load https://www.abc.ca.gov/datport/lqs.html?rpttype=5 this URL using Java/Groovy to extract information from this webpage. It inloves Request using POST method. Please help to resolve.
Using InteliJIdea and Groovy.
JSoup and Groovy can easily load the page using this:
#Grab('org.jsoup:jsoup:1.7.1')
// The URL to scrape
String url = "https://www.abc.ca.gov/datport/lqs.html?rpttype=5"
// Connect and get URL via Jsoup
def doc = org.jsoup.Jsoup.connect(url).get()
// Output the entire HTML page
println doc
The table displayed on the page is retrieved with Ajax, and to retrieve that, you would need to parse the JSON from the request made with Javascript.
It might be easier for you to try using Geb, which can wait for the page beeing loaded with data, and then you can scrape it.
I want to get a html page content from a url using NodeJS after JavaScript is fully loaded and the page is completely rendered, or get the basic html then run all JavaScript files to achieve final content.
For example let's assume there is a website based on AngularJS, so the basic html is simple, but after loading all JavaScript codes in the page, page content is completely different. I want to get that final content on my server to find something in it. Any ideas?
After-Load is a NodeJS package that works like a charm :
var afterLoad=require('after-load');
then :
afterLoad('http://stackoverflow.com/questions/29366718',function(html){
console.log(html.indexOf('charm')>0);
//true
})
Maybe it's too late, but back in the day, PhantomJS solved my problem.
I have a simple request for Xpages app. I have calculator like page where user enters some data and after submission (button action with full submit e,g, 'Export to PDF' button) app should create PDF and return back to browser. Everything is actualy working fine for me except that this works first time only. It returns PDF back to browser but then browser page stops working ... buttons or ajax partial refreshes dont work anymore. I understand its related to fact that browser submits data to server and expects payload come back but instead I'm sedning PDF file but how to handle it different way? I need the page submit because I'm managing the viewState for page that is necessery for me when rendering PDF content ... Any idea how to solve it properly?
Here is my code I'm using for sending PDF back to browser.
ExternalContext exCon = DominoAccess.getFacesContext().getExternalContext();
HttpServletResponse response = (HttpServletResponse)exCon.getResponse();
ServletOutputStream out = response.getOutputStream();
response.setContentType("application/pdf");
response.setHeader("Content-disposition","attachment; filename="+fileName);
response.setHeader("Cache-Control", "no-cache");
//Get the document out to the screen
createPdf(out,html);
// Stop the page from further processing;
DominoAccess.getFacesContext().responseComplete();
I have a problem where I load a URL in UIWebView. The URL redirects to a different location.
I handle this redirect with the following code:
- (NSURLRequest *)connection:(NSURLConnection *)inConnection willSendRequest:(NSURLRequest *)inRequest redirectResponse:(NSURLResponse *)inResponse {
if(inResponse) {
NSMutableURLRequest *req = [[inConnection originalRequest] mutableCopy];
[req setURL:[inRequest URL]];
return req;
}
return inRequest;
}
However, when the page loads, I get 404 on all the images. I can load the URL in Safari without any problems. This is happening on iOS6.1 and iOS7
I'm completely stumped as to what to do.
Unfortunately, I don't have access to the server, so I have to handle everything in my app.
Thanks for any advice.
Ah okay,
So what seems to have been happening, is that the my custom auth protocol was handling the initial request, then when the redirect request came in, a second caching protocol was intercepting the request for the images and breaking the redirect.
In the authprotocol, in the startLoading method I do the following:
[NSURLProtocol setProperty:#YES forKey:#"AuthSet" inRequest:newRequest];
So in the caching protocol's canInitWithRequest method I do the following:
if([NSURLProtocol propertyForKey:#"AuthSet" inRequest:request] != nil)
return NO;
Since, when we are caching, we have no need to follow redirects. So basically if the Auth protocol grabs the request, the caching protocol should not respond to it.
Will update after some testing to see if there are any other side effects.
I'm trying to load myframe.html inside an iframe and attach that iframe to the DOM of the current page. Is this possible, if myframe.html is part of my extension source?
I was thinking something like
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "myframe.html"); //what would be my path here, if this were possible?
document.body.appendChild(iframe);
It should be possible, use a content script to inject javascript into the page and then use the chrome.extension.getURL() method to get the correct URL to your file hosted inside your extension