Need Help!

WBOY
Release: 2024-08-16 17:03:40
Original
557 people have browsed it

Need Help!

Hi I am in need of help from someone who is proficient in webscraping as I am new to programing. I have an assignment to extract the "about client" section from the job links. My script extracts only one "about client" but for other links it doesnot do that and throws error. The thing is there is xml file link from which I am extracting the job links and when those links are opened the html code is under java script for wich i am using selenium. I hae tried everything but didn't got the solution.`def extract_client_info(job_url):
client_info = {'About the Client': np.nan}

if job_url and job_url != "N/A": try: # Open the job URL driver.get(job_url) # Wait for the page to load WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.CSS_SELECTOR, '.cfe-about-client-v2')) ) # Extract specific details about_client_section = driver.find_element(By.CSS_SELECTOR, '.cfe-about-client-v2') client_location = about_client_section.find_element(By.CSS_SELECTOR, '[data-qa="client-location"]').text.strip() client_job_posting_stats = about_client_section.find_element(By.CSS_SELECTOR, '[data-qa="client-job-posting-stats"]').text.strip() if about_client_section.find_elements(By.CSS_SELECTOR, '[data-qa="client-job-posting-stats"]') else "N/A" client_company_profile = about_client_section.find_element(By.CSS_SELECTOR, '[data-qa="client-company-profile"]').text.strip() # Combine extracted information client_info['About the Client'] = ( f"Location: {client_location}\n" f"Job Posting Stats: {client_job_posting_stats}\n" f"Company Profile: {client_company_profile}" ) except Exception as e: print(f"Failed to get 'About the Client' for {job_url}: {e}") client_info['About the Client'] = np.nan finally: # Wait for 10 seconds before making the next request time.sleep(10) return client_info`
Copy after login

The above is the detailed content of Need Help!. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!