How can I retrieve just the intro text (those few lines at the beginning of each article), using java?
I've seen a question like this here, the problem is that the code was in PHP and I need it in java so I can implement it to my android app...
I've tried to search all GitHub for some easy libraries that could help me get what I want and I got no success.
I've also seen that this link: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=Stack%20Overflow shows information about whatever I want to search. I just can't retrieve the data because, as I said, in that question, the code posted was in PHP
check this https://www.mediawiki.org/api/rest_v1/#!/Page_content/get_page_summary_title
Api for accessing content is here , rest you can normally parse the data.
hope this helps.
Related
Short version: Please give me a recommendation to the best place to post a question helping me convert a PDF to TEXT using JAVA programming.
Details:
I've been working on trying to change a PDF to a text file using JAVA and keep the format as close to the PDF's as possible. I've currently been using a separate,free, third party program to do the converting and then the JAVA program I made does everything else I want. I've asked around a lot of places and most recommend PDFBox which didn't work. All PDFBox did was the same thing Adobe Read X would do, which is create a huge bunch of text mess. I've tried a lot of things and spent a lot of time on this. What I'm going to do now is share one of the PDF's I been trying convert and hopefully someone can help me with some JAVA code that will help convert this. I've only really got permission to share this old file once (even thou I'm 99% sure it would be fine to share the file a few other places) and I would like post the question at the most effect spot.
Well short version (and to actually answer my actual question)
Answer is: http://stackoverflow.com
Special Thanks to #TilmanHausherr who went above and beyond by following my updates and helping me more.
Longer version.
I'm still having some formatting issues but I think I'll be able to find the rest on my own. As far as what I asked for getting the document formatted correctly using Java, that's done. As far as the question was asked this document is kind of formatted correctly it just doesn't look as pretty as some other things I've used.
After that, I got stuck because the formatting would not be correct after the conversation. I've asked around before and most said it would be too hard to explain. In the end I've had to re-learn how to attach PDFBox, trouble shoot through common problems others have had, and a single line of code from TilmanHausherr as shown in the comments helped.
When I started this project I had to learn how to get PDFBox to work with my IDE and how to arrange libs. and such. I then went on to find some old googled codes that used PDFBox to convert text from a PDF. I can't share the code used to do the converting but it takes about 4 to 5 mins to search for the original posters work. There still some modifications I had to do to their code just to get it to work, but I just followed prompts from my IDE: Eclipse.
I used this code to write to the text file instead of a Formatter.:
String textFromMain = textForAll;
try( PrintWriter out = new PrintWriter( "text.txt" ) ) {
out.println( textFromMain );
}
Today I want to know how to get image URL from webSite,
I already read some questions and answers but they're not quite perfect for me.
The problem is, when I enter the site, there are some images. It's pretty easy that I get image URl by UI, But, it's really hard that I get image URL by Java Servlet and jsp. Sometimes, some image url is in only networks!
For example, http://map.daum.net/ <-- this site.
Enter the site, and see 'RoadView'. When you see Codes in Chrome(F12), there are no image sources in jsp codes. Only you can see in Networks!
How can I get image URL(source)? Is it possible?
ps. I can get image source using mouse and right click, but I want to get image source using java automatically :), so please do not write user's perspective.
ps2. I'm not very well using English, so there are so many mistakes and something like rude. I apologize for that.
So, what you want to do is to scrape a dynamic content of the page to extract some dynamically loaded data (an image url) from it. You did not tell us what programming language or environment you want to use. However, similar questions have been asked before, for instance this one: How to scrape ajax loaded content with jsoup. There are two frameworks named in the answers to this question: PhantomJS and CasperJS. Both are JavaScript frameworks.
This is my first post in Stackoverflow. I'm a beginner in android and currently developing an app that uses a QR Scanner. The process is as below.
There're several objects with QR codes attached
App scans one QR code
Get the data retrieved related to that specific object (ex: name of the object, description of the object, images) from a remote MySQL database
Show the data in the app
So this is the simple process of the app. I do not know any technologies that I can use to achieve this since I'm a beginner. I would be obliged if someone could explain how I can do this.
Edit : This is different from directly calling data from MySQL database since it involves a QR code scanning part also. I can get the data from MySQL database and show it in android. But the complex part is how to get data automatically shown in the app after scanning the QR code. I have integrated Zxing QR Scanner.
Thank you.
According to your description, there are 2 main tasks you have to accomplish:
Scan QR code.
Retrieve info from a web service (which is backed by MySQL).
For (i), you would use popular QR Scanner libraries such as ZXing and ZBar. Using such libraries would require you to write some extra custom classes, just follow their instruction.
For (ii), you would use a networking library such as Retrofit, Volley, ... to get data from the web service.
Have you done any own research before asking here?
Nevertheless you can achieve your solution by trying out these steps:
1.) You need an API to scan your QR Code. By searching via Google i instantly found this page: http://code.tutsplus.com/tutorials/android-sdk-create-a-barcode-reader--mobile-17162 Here you can implement a barcode reader (but it also is able to read QC Codes as I understand)
2.) You need to find out which content the QR codes includes (e.g. an unique ID or something like that so you can identify your article)
3.) You need a database (e.g. you could use Apache Tomcat which includes a mySql database) where these IDs are stored.
4.) Your android app has to communicate with the server/database with e.g. webservices (you can google it, you will find some ways to implement webservices)
Still I can't you price "the" solution. You have to use google, read different tutorials and find out how you can solve your problem. If you are expecting difficulties you can still ask here.
I hope I still could help you a little.
Hey guys what's up? I'm making a very simple game for BlackBerry Curve 8520, and i need to get the ranking from the server. In order to get this data, the web programmers gave me php files that gets the data from the database and returns it as a dynamic xml file.
My question is:
How can i load that php file using java code? how can i pass a get parameter to that request?
how can i parse the xml retrieved from the php script?
Thanks in advance!
Francisco
You really have two problems here, and I think you should attempt to address them separately.
Problem 1 is getting the data from the Server
Problem 2 is parsing the data you get from the Server.
Both these problems have been covered extensively on this and other forums previously, so I suggest that you search here and elsewhere. Here are a few links from SO:
blackberry HttpConnection.GET
Parse XML file on BlackBerry
In addition, I recommend you review the documentation provided on the official BB site:
http://developer.blackberry.com/bbos/java/
including the following:
http://developer.blackberry.com/bbos/java/documentation/intro_networking_1984362_11.html
As you will see, the BB offers a number of methods of doing communication, in your case I would recommend the ConnectionFactory API:
http://developer.blackberry.com/bbos/java/documentation/network_api_1984363_11.html
And here is something on parsing XML:
http://supportforums.blackberry.com/t5/Java-Development/Use-the-XML-Parser/ta-p/445210
This should be enough to get you going. Please come back with specific questions if you have issues with any of this.
I am want to read and display top 200 comments on a video on youtube. Basically when I go to the link: http://gdata.youtube.com/feeds/api/videos/EokUNzGJBI8/comments I get all the comments in rss feed form. How do I parse and read all the comments?
Edit: I have tried the same in php and it's quite easy to retrieve. I need to do it in Java and I am new to it.
You can take the following steps in code:
Load that API in Java - make the call by Downloading the Contents of that Page
Parse the XML using a Java XML Parser
Loop through the comments and do what you will.