Python Selenium Tutorial #3 - Web Scraping to Excel

preview_player
Показать описание
In this concluding part of the tutorial, we will show you how to move web scraping data to Excel. That is from the Morningstar webpage and land it in an Microsoft Excel spreadsheet in a CSV format.

This Selenium tutorial for beginners module has been structure with easy to follow steps. We will introduce you to the world of web scraping with Python Using Selenium. The core scripting language (Python) has also been structure as a Python for beginners.

Web scraping is a very neat and at times very powerful technique to acquire data from another website, and data is knowledge and "power".
This tutorial, we will show you how to perform web scraping using Selenium and Python, and after which parse (or output) the data into the Microsoft Excel spreadsheet for further manipulations.
We will show you how to install Python and Selenium, basic background on different libraries, illustrate typical gotchas in web scrapping and how to output the scrapped data into an Microsoft Excel spreadsheet.

We hope that Python Selenium Tutorial will be handy for your new web scraping projects.

I am using Morningstar webpage to show you how to perform web scraping.

Source Code For Python:

Xybernetics Article:

Python:

Sublime:

--

Also find us on:

#Python, #Webscrapping, #Selenium, #pythontutorial, #Excel,
Рекомендации по теме
Комментарии
Автор

this is exactly what i am looking for with my project. you are a superstar, thank you so much!!!! 🤘

LiverpoolDon
Автор

where is the actual loop writing part? The video ends abruptly

magalarova
Автор

Hi
Using whatsapp web, need to Download all the images and texts in a whatsapp group or chat in a single click

images in a seperate folders.
(texts with date and time) in the excel file

is it possible?

lazarselva
Автор

Thank you ! Its very simple to understanding !
But why we dont close the fiel with f.close()

vgkjmxz
Автор

You tried hard to explain everything. Very good. Keep it up. Good wishes to you but try to make your code cleaner :)

LOL-cszo
Автор

Excelent video!

I am a Python begginer, studying for about 3-4 months and this is my first time trying to webscrap and I got successful!

Just one question... I am using my program to web scrap an used cars website. My goal is to scrap all the cars in the website, but the way we did in this video, I am just receiving the information of the first car!

Could you help me?

This is my code:

from selenium import webdriver
from import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import os.path
from os import path


#primeiro bloco, criando um CSV já com um codificador. Já coloquei um cabeçalho. Verifica se a planilha já existe pra não fazer o cabeçalho dnv.

plan="WebScrapPrecos.csv"
FileExists = 1
if not path.exists(plan):
FileExists = 0
f = open(plan, "a", encoding="utf-8")
if FileExists ==0:



#segundo bloco, abrindo o site e chegando até a pesquisa de ('t-cross") na Webmotors.
navegador = webdriver.Chrome()
time.sleep(3)

time.sleep(5)


#Terceiro bloco, procurando o elemento relativo ao nome T-cross e salvando em uma variavel.
nome = nomes[0].text
print(nome)


#Quarto bloco, procurando o elemento relativo ao modelo da T-cross e salvando em outra variavel.
modelo = modelos[0].text
print(modelo)


#Quinto bloco, procurando o elemento relativo ao Preço da T-cross e salvando em outra variavel.
preço = preços[0].text
print(preço)


#Sexto bloco, procurando o elemento relativo ao Ano da T-cross e salvando em outra variavel.
ano = anos[0].text
print(ano)


#Sétimo bloco, procurando o elemento relativo à quilometragem da T-cross e salvando em outra variavel.
quilometragem = quilometragens[0].text
print(quilometragem)

f.write("\n" + nome + ";" + modelo + ";" + preço + ";" + ano + ";" + quilometragem)

gustavofornari