I tried Web_Scraping using Beautiful Soup in python.But I facing Issue for captcha.I tried for get data to website using beautiful soup in python but its asking human verification how to solve this Issue any one give me solution ...plz
webscrapy.py
from bs4 import BeautifulSoup
from urllib.request import urlopen
import html5lib
import requests
import urllib
import pandas as pd
import xlsxwriter
from docx import Document
from docx.shared import Inches
document = Document()
url = "https://www.newegg.com/Product/ProductList.aspx?Submit=ENE&DEPA=0&Order=BESTMATCH&Description="
Remaining_url="&ignorear=0&N=-1&isNodeId=1"
product_name = 'HP Desktop Computer 6200 Intel Core i3 2nd Gen 2100 (3.10 GHz) 4 GB DDR3 250 GB HDD Windows 7 Professional 64-bit'
p = document.add_paragraph("Product_name " +":"+" "+product_name)
search_words = {'text': product_name}
search_url = urllib.parse.urlencode(search_words).split("=")[1]
product_url = url + search_url + Remaining_url
print(product_url)
# content = urlopen(product_url).read()
content = requests.get(product_url, timeout=20)
if content.status_code == 200:
content = urlopen(product_url).read()
soup = BeautifulSoup(content, "html5lib")
product_list = soup.find_all("div", class_="list-wrap")[0].find_all("div", class_="item-container")[0].find_all("a", class_="item-img")[0]
convert_string = str(product_list).split('"')[3]
content = requests.get(convert_string, timeout=20)
if content.status_code == 200:
content = urlopen(convert_string).read()
soup = BeautifulSoup(content, "html5lib")
print(str(soup.find_all("div", class_="grpAside")[0].find_all("span",class_="mainSlide")[0]).split(" ")[3].split('"')[1])
else:
print("Its TimeOut")
else:
print("Its Timeout")
Aucun commentaire:
Enregistrer un commentaire