T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.ca/private_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.ca/private_html/scripts/scrape-barreau-profile.js
const axios = require('axios');
const cheerio = require('cheerio');

const BARREAU_SEARCH_URL = 'https://www.barreau.qc.ca/fr/trouver-un-avocat/resultats/?n=';
const BARREAU_BASE_URL = 'https://www.barreau.qc.ca';

async function scrapeBarreauProfiles(name) {
  const searchUrl = BARREAU_SEARCH_URL + encodeURIComponent(name);
  const searchRes = await axios.get(searchUrl, {
    headers: {
      'User-Agent': 'Mozilla/5.0',
      'Accept-Language': 'fr-CA,fr;q=0.9,en;q=0.8',
    },
    timeout: 10000
  });
  const $ = cheerio.load(searchRes.data);

  // Find all profile links
  const profileLinks = [];
  $('.result-item a[href*="/fr/trouver-un-avocat/membre/"]').each((i, el) => {
    const href = $(el).attr('href');
    if (href && !profileLinks.includes(href)) profileLinks.push(href);
  });

  if (profileLinks.length === 0) {
    console.log('No profiles found for', name);
    return;
  }

  for (const relLink of profileLinks) {
    const profileUrl = relLink.startsWith('http') ? relLink : BARREAU_BASE_URL + relLink;
    try {
      const profileRes = await axios.get(profileUrl, {
        headers: {
          'User-Agent': 'Mozilla/5.0',
          'Accept-Language': 'fr-CA,fr;q=0.9,en;q=0.8',
        },
        timeout: 10000
      });
      const $$ = cheerio.load(profileRes.data);
      const name = $$('h1, .profile-title, .nom').first().text().replace(/^Me\s+/i, '').trim();
      const employer = $$('.profile-employer, .employeur, .societe').first().text().trim() ||
        $$('.profile-section:contains("Société")').next().text().trim();
      const address = $$('.profile-address, .adresse').first().text().replace(/\s+/g, ' ').trim() ||
        $$('.profile-section:contains("Adresse")').next().text().replace(/\s+/g, ' ').trim();
      const phone =
        $$('.profile-phone, .telephone').first().text().replace(/[^\d]/g, '').trim() ||
        $$('.profile-section:contains("Téléphone")').next().text().replace(/[^\d]/g, '').trim();
      const email =
        $$('.profile-email, .courriel').first().text().trim() ||
        $$('.profile-section:contains("Courriel")').next().text().trim() ||
        $$('.profile-section:contains("Email")').next().text().trim();
      const barNumber = $$('.profile-bar-number, .numero-barreau').first().text().trim();
      let practiceAreas = [];
      $$('.profile-section:contains("Domaines de droit")').next().find('li').each((i, el) => {
        practiceAreas.push($$(el).text().trim());
      });
      if (practiceAreas.length === 0) {
        $$('.profile-section:contains("Domaines de droit")').next().text().split(/\n|,/).forEach(val => {
          if (val.trim()) practiceAreas.push(val.trim());
        });
      }
      let languages = [];
      $$('.profile-section:contains("Langues")').next().find('li').each((i, el) => {
        languages.push($$(el).text().trim());
      });
      if (languages.length === 0) {
        $$('.profile-section:contains("Langues")').next().text().split(/\n|,/).forEach(val => {
          if (val.trim()) languages.push(val.trim());
        });
      }
      const year = $$('.profile-section:contains("Année")').next().text().trim();
      const section = $$('.profile-section:contains("Barreau de section")').next().text().trim();
      const status = $$('.profile-section:contains("Statut")').next().text().trim();
      const profile = {
        name,
        employer,
        address,
        phone,
        email,
        barNumber,
        practiceAreas,
        languages,
        year,
        section,
        status,
        profileUrl
      };
      console.log('\n--- Profile ---');
      console.log(JSON.stringify(profile, null, 2));
    } catch (err) {
      console.error('Error scraping profile:', profileUrl, err.message);
    }
  }
}

// Entry point
const nameArg = process.argv[2];
if (!nameArg) {
  console.log('Usage: node scripts/scrape-barreau-profile.js "Lawyer Name"');
  process.exit(1);
}
scrapeBarreauProfiles(nameArg); 

CasperSecurity Mini