Get data from specific webpage - java

I need to get data from table id="maintable" from website "http://trackinn.az/GeoLoc/reports.aspx?login=ho&password=ho". I tried many methods some of them worked for other websites but not for this one. Could someone help pls?
Thanks.

You cannot get data from that table. It is being dynamically created by javascript (AJAX particularly). And I don't think there is any api wich can process javascript.
It would be possible to get data if it was a static file or the part you want would be static, but it is not.
If you are using this site to get geolocation, then use google geocoding api for this. it would be better option.

Related

Java - use searchbar on given website

Let me just start by saying that this is a soft question.
I am rather new to application development, and thus why I'm asking a question without presenting you with any actual code. I know the basics of Java coding, and I was wondering if anyone could enlighten me on the following topic:
Say I have an external website, Craigslist, or some other site that allows me to search through products/services/results manually by typing a query into a searchbox somewhere on the page. The trouble is, that there is no API for this site for me to use.
However I do know that http://sfbay.craigslist.org/search/sss?query=QUERYHERE&sort=rel points me to a list of results, where QUERYHERE is replaced by what I'm looking for.
What I'm wondering here is: is it possible to store these results in an Array (or List or some form of Collection) in Java?
Is there perhaps some library or external tool that can allow me to specify a query to search for, have it paste it in to a search-link, perform the search, and fill an Array with the results?
Or is what I am describing impossible without an API?
This depends, if the query website accepts returning the result as XML or JSON (usually with a .xml or .json at the end of url) you can parse it easily with DOM for XML on Java or download and use the JSONLibrary to parse a JSON.
Otherwise you will receive a HTML that is the page that a user would see in a browser, then you can try parse it as a XML but you will have a lot of work to map all fields in the HTML to get the list as you want.

Parse a website with jSoup

I am trying to parse a website, specifically this one It does not provide a api for that, like it does for bf4 or other titles, but the owner said that I should just parse the data.
The problem I have is that using jSoup, it retrieves the data, but if you look carefully, the website makes a new httpget and only after that the search is completed.
From what I could gather, i think it sends some paramethers in the header to.
If i just use jSoup to call that like I get some data, and where the search should be I get the message:
Please activate Javascript to see the search results.
Is there is a way to get the data? I really need this, any help is very much appreciated.
Please help
You need a javascript-capable client, e.g., HtmlUnit or Selenium.

How to programmatically create and manage Google Forms via Google Document List API

We have a very specific need. We want to create a generic (Java based) registration system for Event organizers. So every Event organizer can define a custom form on our application, and then we collect the data from users for that particular event.
Now the input fields can change from Event to Event, so I was thinking to use some out-of-box cloud solution. One obvious thing came to my mind was to use Google Forms. So for every event, if we can programmatically create a Google Form and get following 2 things:
1) Embed link for that form
2) Access to corresponding data keeping Google Spreadsheet
We can use the embed link to show the Registration form to users on Event page. And we can access the Google Spreadsheet to access the data that Users have been filling in the Registration form.
But when I searched for it, I couldn't get a clear way to achieve this. There is some Google Documents List API, through which you can create Google documents programmatically, but I couldn't figure out, how to meet our needs through this API.
It would be of great help, if somebody can guide us in this regard. Or suggest us any alternate cloud solution.
UPDATE::
Looks like Google doesn't provides an API at all for Forms linked with Spreadsheets. http://goo.gl/ia8rk If we are lucky, they might include in their future releases.
So any other cloud based API that can be handy for this problem??
If I understand correctly, you have a Google sheet and you want a way to automatically generate a form. That generated form should link its responses back to that spreadsheet. Is that correct?
I don't know a way to do that with Java (if there is an available API for that, I don't think so) but that can be easily accomplished with Google Scripts. This was built in the script editor of a Google Spreadsheet.
Here is an example:
function onOpen() {
// read the docs to add to the toolbar
}
function getColumnHeaders() {
// this grabs the headers of your sheet
var headers = SpreadsheetApp
.getActiveSheet()
.getRange(1, 1, 1, SpreadsheetApp.getActiveSheet().getLastColumn())
.getValues()[0];
// this will appear in your root directory
var newForm = FormApp.create('NEW FORM NAME');
newForm.setDestination(FormApp.DestinationType.SPREADSHEET, SpreadsheetApp.getActiveSpreadsheet().getId());
headers.forEach(function(each) {
newForm.addTextItem().setTitle(each);
});
}
The documentation can be found here: https://developers.google.com/apps-script/reference/forms/

parsing web page which is changing real time in JAVA

Heres what i want to do. Im quite a beginner with this so maybe a lame question, But, I want to implement gui application in java wich gets data from sports livescore pages
e.g
http://www.futbol24.com/Live/
http://livescore.com/
and parse it (somehow) in my app...and then i will be able to store it in for example jtable ,save full time results in database,playing sounds after goal is scored and so on
What is the best way to do this ?
It would be almost impossible to parse an HTML document from a live web page and get specific information from it. If you did manage to work out exactly where in the document the data is, the page structure could change at any time. The scores might not even be in the HTML - they could be fetched by Javascript in the page.
I suggest you find an RSS feed of the information you want. Then you'll only have a nice, small piece of XML to parse. That's what it's for.

Best way to handle large amounts of static text, images when creating pdf using iText

We are going to use iText to create a large report. There will be a lot of static text and images that will be the same for every report. We will then insert dynamic data from a database into the report. The static data and the dynamic data will be mixed together when the report is finished. What is the best way to handle the static data. We are going to use a java servlet in a web application for the creation of the report. We want the report to be sent to the web page immediately, so performance is critical.
These are some of the ideas I had. Not sure if any of these are good ideas.
1.) Create a PDF with the static content then insert the dynamic data. If I go this way how would I know where to insert the dynamic data? Is it possible to bookmark place to insert data?
2.) Get the static data from a database. This seems like it would be difficult trying to design a database with static content that would have to consider things like pages, paragraphs, headings, images. I would also think that this would not be great for performance if the website gets hit hard.
3.) Cache the static content in the servlet context. This would seem to help performance but would still have the same design issues as the database.
I would love some opinions on the best way to store large amounts of static text when creatig a PDF using iText.
Thanks for your help
Doug
I am not sure if the best way to do it, but this worked well for me in a similar situation, I created a template file that I read into code, and in the template I had hash tagged variable holders that I used to find a location and replace with dynamic text from whatever source. For example:
Hello #CUSTOMER_NAME#, Thank you for the purchase of #RECENT_PURCHASES# on
#RECEIPT_DATE#, for a total value of #RECEIPT_TOTAL#. ...
Like I said, it probably isn't ideal, but it really well for my needs.

Categories