Skip to content

Commit

Permalink
Add example code for webscraping
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyouMB committed Oct 19, 2024
1 parent c2d3b0a commit d685a62
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions content/hackthetunnels/2024-2025/challenges/11-web-scraper.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,24 @@ preview: "images/event_posters/2023-2024/hack_the_tunnels.jpg"

Create a web scraper that extracts course data from the [Carleton Central schedule page](https://central.carleton.ca/prod/bwysched.p_select_term?wsea_code=EXT). The scraper should retrieve details such as course codes, titles, and available sections for a given term.

If you're not sure where to get started, see this [guide.
](https://www.freecodecamp.org/news/the-ultimate-guide-to-web-scraping-with-node-js-daa2027dcd3/)
<br/>
If you're not sure where to get started, here is some starter code:

```typescript
import axios from 'axios';
import * as cheerio from 'cheerio'; // Use this syntax for compatibility

const scrapeData = async () => {
const { data } = await axios.get('https://central.carleton.ca/prod/bwysched.p_select_term?wsea_code=EXT');
console.log(data); // Logs raw HTML content

const $ = cheerio.load(data); // Initialize Cheerio with loaded HTML
console.log($('title').text()); // Example: Print the <title> content
};

scrapeData();
```

To run this code, you'll have to `npm i axios` and `npm i cheerio`.

## Acceptance Criteria:

Expand Down

0 comments on commit d685a62

Please sign in to comment.