1

I'm working on a Chrome Extension and I was essentially hoping to populate a <div> tag in the popup with some Related Links, set up by taking some search results links from Google.com by using jQuery.load(search_url) to inject them into the <div>.

I guess the first question would be to ask if Google has set up their page so you can't pull content from it (legality issues?). Otherwise, I'm pulling from the "r" class which contains one of the search results hyperlink. Here's the code:

$(document).ready(function(){$('#links').load("https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&es_th=1&ie=UTF-8#q=keyWords .r");});

(Keywords will eventually be replaced with the relevant keywords to search for).

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
A13X
  • 409
  • 1
  • 6
  • 27

2 Answers2

1

This post basically summarizes why it doesn't work: Is it ok to scrape data from Google results?

Rightly so, they don't want people pinging their webpages like that and pulling all that data from their servers. Google does have an API I could use, but I think I may just get rid of that feature altogether, people are perfectly capable of searching for relevant material [via Google of course :) ].

Community
  • 1
  • 1
A13X
  • 409
  • 1
  • 6
  • 27
0

I worked on a project where I made it open links for my chrome extension as well. I used this simpler function and it worked without problems:

window.open(*string variable here*);

However, for Chrome extensions specifically, try chrome.tabs.create({url: "..."});

btrballin
  • 1,420
  • 3
  • 25
  • 41
  • This actually ended up being a good idea for my purposes. Now it searches keywords based on the current pages' title/other relevant tags. Thank you. – A13X Jul 16 '16 at 23:01
  • 2
    There may be problems using `windows.open()` from extension code (such as rate limiting). A more extension-like way to do it is `chrome.tabs.create({url: "..."})`, which does not require `"tabs"` permission. – Xan Jul 18 '16 at 13:17