Giter Site home page Giter Site logo

gabrielabezerra / buscaweb Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 7.11 MB

Using Depth-First Search (DFS) to find the URLs between two websites, given the amount of tries.

Shell 0.05% Python 99.84% PowerShell 0.11%
python crawler beautifulsoup4 selenium dfs-algorithm

buscaweb's Introduction

BuscaWeb

Using Depth-First-Search (DFS) to find the URLs between two websites, given the amount of tries.

Authors: Gabriela Bezerra, Guilherme Araújo, Ítalo Bruno, Pedro Moura.

Implemented with Python 3.8.5 and Beautiful Soup 4.

Getting Started

Enter the project's venv

source buscaweb/bin/activate

Install the dependencies

pip install -r requirements.txt --user

Setup the script as executable

chmod +x crawler-busca-web.py

Run the script

./crawler_busca_web.py "http://pyfound.blogspot.com" "https://careers.google.com" 9

Another way to run the script would be

python crawler_busca_web.py "http://pyfound.blogspot.com" "https://careers.google.com" 9

Usage

./crawler_busca_web.py <https://www.origin.com> <https://www.destiny.com> [<amount of searches allowed>]

📚 Many pages make a thick book.

YouTube Video with code explanation in portuguese

A short (informal) general explanation of the algorithm workflow.

This algorithm consists of the following steps: (simplified step-by-step description)

  1. Define 3 main inputs: origin url, destiny url and the search limit amount.
  2. Initialize the seen urls list, the processing stack and the search counter.
  3. Add the origin url to the processing stack.
  4. Verify if the search limit amount has been reached by the search counter. 3.1. If it did, print all the seen urls then End program. 3.2. If it didn't, continue the algorithm.
  5. Process the last url of the stack by checking if it is the destiny url and append it to the seen urls list. 4.1. If it is, the algorithm prints all the urls between the origin url and the destiny url then End program. 4.2. It it isn't, continue the algorithm.
  6. Make a GET request to the processed url and increment search counter.
  7. Read the html page returned by the request.
  8. Create a children urls list and append all the urls found inside any <a href=''> tag to it.
  9. Check if the children urls list contains the destiny url. 8.1. If it does, the algorithm prints all the urls between the origin url and the destiny url then End program. 8.2. If it doesn't, append all the urls of the children urls list to the processing stack.
  10. Go back to step 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.