James Hancock
asked on
Help save me money on Custom Search Engine dev time calls
Hi
I am doing Google Custom Search in a Java program, and it is charging me $5 per 100 calls. This will add up during my dev window,
and I'd like to hardcode a response to help keep costs minimal.
This portion grabs the Results List... which are URL's
Result is part of the Google Custom Search API
public static void main(String[] args) throws GeneralSecurityException, IOException {
List<Result> items = new ArrayList<Result>();
for (long i = 1; i <= 1; i += 1) { // enter bigger numbers for bigger results
items.addAll(executeSearch ("Search Terms", i));
}
StringList latestResultsLinksList = new StringList(items.size());
StringList TitlesList = new StringList(items.size());
for(Result r : items) {
latestResultsLinksList.add (r.getLink ());
TitlesList.add(r.getTitle( ));
}
How might I hardcode the latestResultsLinksList to equal specific URL strings in code?
Could this be in a separate class, to minimize extra blocks of code?
StringList java class is attached
Example output is below, a simple search for 'Mickey Mouse'
About 25000000 results available
0: Mickey Mouse - Wikipedia, the free encyclopedia, , http://en.wikipedia.org/wiki/Mickey_Mouse
1: Mickey Mouse Barack Obama Shirt - Those Shirts, , http://www.thoseshirts.com/mic.html
2: Rand Paul hits Obama for playing 'Mickey Mouse games' – CNN ..., , http://politicalticker.blogs.cnn.com/2013/03/11/rand-paul-hits-obama-for-playing-mickey-mouse-games/
3: Mickey Mouse Clubhouse - Mickey's Fishy Story - YouTube, , http://www.youtube.com/watch?v=PC2jgDyJqBo
4: Obama attorney: 'Mickey Mouse' could be on ballot - WND, , http://www.wnd.com/2012/04/obama-attorney-mickey-mouse-could-be-on-ballot/
5: Mickey Mouse Clubhouse - Online Activites and Fun | Disney Junior, , http://disney.go.com/disneyjunior/mickey-mouse-clubhouse
6: ACORN: Mickey Mouse for Obama? | The Economist, , http://www.economist.com/node/12432392
7: Mickey Mouse follows Obama in backing gay marriage - The Guardian, , http://www.guardian.co.uk/world/2012/may/17/mickey-mouse-gay-marriage
8: Chris Matthews: Obama “Big Bird” Ad is “Mickey Mouse”, , http://www.aim.org/don-irvine-blog/chris-matthews-obama-big-bird-ad-is-mickey-mouse/
9: Mickey Mouse makes an appearance - The Washington Post, , http://www.washingtonpost.com/business/mickey-mouse-makes-an-appearance/2013/07/06/d9561d8e-df60-11e2-b2d4-ea6d8f477a01_story.html
StringList.java
I am doing Google Custom Search in a Java program, and it is charging me $5 per 100 calls. This will add up during my dev window,
and I'd like to hardcode a response to help keep costs minimal.
This portion grabs the Results List... which are URL's
Result is part of the Google Custom Search API
public static void main(String[] args) throws GeneralSecurityException, IOException {
List<Result> items = new ArrayList<Result>();
for (long i = 1; i <= 1; i += 1) { // enter bigger numbers for bigger results
items.addAll(executeSearch
}
StringList latestResultsLinksList = new StringList(items.size());
StringList TitlesList = new StringList(items.size());
for(Result r : items) {
latestResultsLinksList.add
TitlesList.add(r.getTitle(
}
How might I hardcode the latestResultsLinksList to equal specific URL strings in code?
Could this be in a separate class, to minimize extra blocks of code?
StringList java class is attached
Example output is below, a simple search for 'Mickey Mouse'
About 25000000 results available
0: Mickey Mouse - Wikipedia, the free encyclopedia, , http://en.wikipedia.org/wiki/Mickey_Mouse
1: Mickey Mouse Barack Obama Shirt - Those Shirts, , http://www.thoseshirts.com/mic.html
2: Rand Paul hits Obama for playing 'Mickey Mouse games' – CNN ..., , http://politicalticker.blogs.cnn.com/2013/03/11/rand-paul-hits-obama-for-playing-mickey-mouse-games/
3: Mickey Mouse Clubhouse - Mickey's Fishy Story - YouTube, , http://www.youtube.com/watch?v=PC2jgDyJqBo
4: Obama attorney: 'Mickey Mouse' could be on ballot - WND, , http://www.wnd.com/2012/04/obama-attorney-mickey-mouse-could-be-on-ballot/
5: Mickey Mouse Clubhouse - Online Activites and Fun | Disney Junior, , http://disney.go.com/disneyjunior/mickey-mouse-clubhouse
6: ACORN: Mickey Mouse for Obama? | The Economist, , http://www.economist.com/node/12432392
7: Mickey Mouse follows Obama in backing gay marriage - The Guardian, , http://www.guardian.co.uk/world/2012/may/17/mickey-mouse-gay-marriage
8: Chris Matthews: Obama “Big Bird” Ad is “Mickey Mouse”, , http://www.aim.org/don-irvine-blog/chris-matthews-obama-big-bird-ad-is-mickey-mouse/
9: Mickey Mouse makes an appearance - The Washington Post, , http://www.washingtonpost.com/business/mickey-mouse-makes-an-appearance/2013/07/06/d9561d8e-df60-11e2-b2d4-ea6d8f477a01_story.html
StringList.java
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, I just copied the area without thinking.
I don't need the title.
The stringList class itself has save and read methods.
Should I just save each search result on my local disk?
And load all of them in on each run, when needed?
I can load in every string in every file in a certain folder to get all existing strings.
Then I get them back the same?
I don't need the title.
The stringList class itself has save and read methods.
Should I just save each search result on my local disk?
And load all of them in on each run, when needed?
I can load in every string in every file in a certain folder to get all existing strings.
Then I get them back the same?
That's ok in principle yes.
ASKER
?