To scrape URLs from web pages using a Rails backend, paired with a Vue.js single-page application.
- This application allows users to input a URL and scrape all the URLs from the page. The scraped URLs are displayed in a table format, showing both the URL and its associated anchor text.
- Additionally, users can view previously scraped URLs from visited pages as shown in the screenshot below.
- Ruby:
3.1.4
- Rails:
7.1.4
- Vue.js:
3.3.13
- Backend: Ruby on Rails
- Frontend: Vue.js
- CSS Framework: Tailwind CSS
- Inside the
scraping_urls
directory, run the following command in a terminal.
docker compose up --build
- Open a browser and view the application at localhost. You should see a running application. In the terminal, press ctrl+c to stop the application.
- Clone the project from GitHub:
git clone https://github.com/hmzasif/scraping_urls.git
- Install dependencies using:
bundle
- If you face further error, please run this command too:
yarn install
- To setup the database, please run:
rails db:create db:migrate
- To seed the development database, run:
rails db:seed
- Copy .env.example to your .env file to set up the environment variables:
cp .env.example .env
- Run the local server:
bin/dev
SourceURL
can have manyScrapedURLs
, forming a one-to-many relationship.
SourceUrl
store the URL of the page to be scraped withurl
field andScrapedUrl
store the URLs scraped from the page withurl
andanchor_text
fields.
In Rails 7, secrets are securely managed using the credentials file. Follow these steps to handle your application secrets:
- Generate a Secret Key: Run the following command to create a new secret key:
rails secret
- Update credentials: You can use any text editor of your choice to update the credentials file, such as
nano
,vim
, orcode
. For example, with code, run the following command:
EDITOR=code rails credentials:edit --environment development
Inside the credentials file, add your secrets. Additionally, If you use password and username for pg, you can add them in the credentials file as shown below
db:
username: your_database_username
password: your_database_password
This application includes MiniTest for unit testing models and functional testing for controllers, ensuring robust validation and expected behavior of the application's features.
The application is deployed on Heroku. You can access the live version here.