Giter Site home page Giter Site logo

allstars-assesment's Introduction

AllStars-Assesment

for the main app.py

It uses Selenium WebDriver and other Python libraries to download web pages from the Class Central website.

The script starts by importing necessary libraries such as Selenium, requests, and hashlib. It defines some global variables such as the base URL of the website, the directory where the downloaded files will be saved, the maximum depth of the recursion when downloading links, and a set to keep track of visited links.

Then the download_page function is defined, which takes a URL and an optional depth parameter. The function first checks whether the URL has been visited before, and if it has, it returns immediately. Otherwise, it visits the URL using a Firefox webdriver, finds all the links on the page, and extracts the HTML source code of the page.

The function then scrolls down the page to load all the images and extracts the title element of the page. It then creates a directory in the base_dir to store the downloaded files and downloads all the images, stylesheets, and scripts on the page. It saves the downloaded HTML source code in a file named "index.html" in the directory.

Finally, the function recursively calls itself on all the links on the page if the depth is less than "max_Depth".

The script then creates a Firefox webdriver, visits the "base_url", and calls the download_page function with the "base_url". After the function is finished, the webdriver is closed.

For the trasnlator script

It translates HTML files in a directory and its subdirectories from English to Hindi using the Microsoft Translator API.

The script creates a Translator object with an API key and defines a function "translate_text" that takes a string of text as input and returns the translated text as output using the translate method of the Translator object.

The "translate_html_file()" function opens an HTML file, parses it using BeautifulSoup, and replaces all text nodes (except those inside script, style, head, and title tags) with their translations using the "translate_text()" function. The translated HTML is then written back to the file.

The "translate_html_files_in_directory()" function recursively walks through a directory and its subdirectories, finds all HTML files, and calls "translate_html_file()" on each file to translate its contents.

allstars-assesment's People

Contributors

mike-brown5 avatar

Watchers

 avatar

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.