I want to make a chrome extension that will take url from browser and pass it to python script that in present in same folder, which will scrape the web page and output a JSON file with data.
Manifest.json
{
"name":"Scraper",
"version":"1.0.0",
"manifest_version":2,
"content_scripts":[
{
"matches":["https://www.amazon.in/*"],
"js":["content.js"]
}
],
"browser_action":{
"default_popup":"popup.html",
"default_title":"Scraper"
},
"permissions":["activeTab"],
"content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'"
}
popup.js
document.addEventListener('DOMContentLoaded',function(){
document.querySelector('button').addEventListener('click',onclick,false)
function onclick(){
chrome.tabs.query({currentWindow:true,active:true},
function(tabs){
var link = tabs[0].url;
chrome.tabs.sendMessage(tabs[0].id,link);
})
}
},false)
myscraper.py
from bs4 import BeautifulSoup as soup
import pandas as pd
import requests
import datetime
import json
current_time = datetime.datetime.now()
my_url = input()
#my_url = 'https://www.amazon.in/Dell-9570-15-6-inch-i7-8750H-Integrated/dp/B08C5DSRHM/ref=sr_1_1_sspa?crid=X09BHN0D2TJA&dchild=1&keywords=dell+xps+15&qid=1597921046&sprefix=dell+xps%2Caps%2C269&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUE1V09ZSFVKVk9aVEcmZW5jcnlwdGVkSWQ9QTAxODcyOTkxQVdJWkxDSFU2UjlZJmVuY3J5cHRlZEFkSWQ9QTA2NTg1NTUxUDJBME5HUE5HS1FaJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ=='
header={
"User-Agent":'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36'
}
page = requests.get(my_url,headers = header)
page_soup = soup(page.content,'html.parser')
title = page_soup.find(id="productTitle").get_text()
price = page_soup.find(id="priceblock_ourprice").get_text()
available = page_soup.find(id="availability").get_text()
avail = available.split(".")
availability = avail[0]
dataPhone = {
'NAME':title.strip(),
'PRICE':price.strip(),
'AVAILABILITY':availability.strip(),
}
with open('amazon.json','w') as json_file:
json.dump(dataPhone,json_file)
content.js
chrome.runtime.onMessage.addListener(function(request){
alert(request)
$.ajax({
url: "./myscraper",
data: {param: link},
}).done(function() {
alert('finished python script');
});
console.log("Finished");
})
popup.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button>Run Python</button>
<script src="jquery-3.5.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="popup.js"></script>
<script src="content.js"></script>
</body>
</html>
Currently the code giving this error "ReferenceError: $ is not defined"
Can someone tell the problem or some other way to do it?
http://essinreceta.com viagra sin receta espaГ±a
http://cialisbob.com/ cost of 5mg cialis daily
https://wardenafil.com vardenafil tablets price
accutane 20mg capsules – buy accutane no prescription accutane online singapore
http://doctorkiva.com erectile pills
https://levitradd.com/ levitra professional samples
https://himscanada.com/ buy cialis canada
http://doctorxep.com low price viagra
buy viagra tablet – ed pills at walgreens viagra buy canada
https://stromectolhumans.com/ ivermectin for humans for sale
https://viagraxyu.com low price viagra
http://iwermectin.com/ ivermectin for humans
modafinil online – provigil 100 mg provigil generic
generic zithromax over the counter – azithromycin side effects zithromax price
where can i get furosemide – medicine furosemide 20 mg furosemide 160
http://ivermectineffects.com/ ivermectin predaj
http://ivermectinovercounter.com/ stromectol
buy cialis 20mg online uk – cialis 20 mg online pharmacy canada cialis generic
http://ivermectineffects.com ivermectin for sale
stromectol nz – ivermectin iv ivermectina 6 mg
community asthma study medical education models
ivermectin https://ivermectinhome.com
big fish casino online – best online casino for money play for real online casino games
http://ivermectinus.com/ stromectol
cheapest ed pills – erectile dysfunction treatment gas station ed pills
https://zithrozpack.com/ zithromax online
levitra 40 mg https://levitrair.com levitra for ed
prednisone 40 – prednisone 20mg pills prednisone 14 mg
sildenafil tablets 100mg cost – viagra prescription viagra best prices
medical school no mcat ny health insurance
stromectol cost https://ivermectinhome.com
ivermectin for sale http://stromectolus.com ivermectin
brand name cialis for sale – Cialis online ordering cialis 5
https://albuterolotc.com/ albuterol without dr prescription usa
why do you need health insurance best medication for hip arthritis
stromectol cost https://ivermectinhome.com
price of stromectol – ivermectin pills canada stromectol 3 mg tablets price
ivermectin side effects http://stromectolus.com ivermectin
ed solutions – cheap medications online erectile dysfunction medications
mn health department nursing home survey results is employer required to pay health insurance when an employee is on workmans comp?
ivermectin tablets for humans https://ivermectinhome.com
how to buy ivermectin https://ivermcov.com/# ivermectin over counter
javascript-help.li vs over the counter medication http://pharmvolk.com over counter drugs that get you high
how to get a mental health evaluation in az http://ventolinhfaer.com/ ventolin inhaler size
javascript-help.li reviewed ivermectin http://ivermectini.com ivermectina
lifewise health plan of washington ivermectin pills for humans http://iveramectin.com how to obtain ivermectin
javascript-help.li vs ivermectin for dogs http://ivermectiny.com ivermectin
how do hospitals lower very high blood pressure https://dapoxetineus.com/ dapoxetine medicine price in india
javascript-help.li recommended ivermectin https://ivermectiny.com ivermectin for sale
viagra prescription needed https://viagrob.com low cost viagra