I want to build a small project on Web Scraping.
During Hacktoberfest or say GSOC when contributors need to solve more number of issues they prefer easy issues like the ones with label Good First Issue, but as during those events there are large number of contributors, one who comments on it first claims the issue. So, for claiming a Good First Issue one needs to constantly look for new issue and comment on it to claim it, which is really tiresome.
So, I came up with an idea to use web scraping libraries like Selenium to keep watch on any new Good First Issue and comment "Claim" on it.
I know how to look out for new issue with Good First Issue label on it. But I don't know how to tackle the main part of commenting on that issue.
Please help me come up with a solution of Watching out on a new Good First Issue and commenting on it to claim it. Is it possible to do it or I should leave the idea?
Edited code with commenting included but getting some errors.
from selenium import webdriver
from selenium.webdriver.common.by import By
website='https://github.com/ToolJet/ToolJet/issues?page=1&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc'
path='C:\\Users\vedant\OneDrive\Desktop'
driver=webdriver.Chrome(path)
driver.get(website)
issue_labels = driver.find_elements(By.CLASS_NAME, "IssueLabel")
for issue_label in issue_labels:
if issue_label.text == 'up-for-grabs':
issue_parent_element = issue_label.find_element(By.XPATH, "..")
issue_grandparent_element = issue_parent_element.find_element(By.XPATH, "..")
issue_link_element = issue_grandparent_element.find_element(By.CLASS_NAME, "Link--primary")
issue_link = issue_link_element.get_attribute('href')
driver.get(issue_link)
comment_box = driver.find_element(By.TAG_NAME, "textarea")
comment_box.send_keys("Claiming this issue")
submit_button = driver.find_element(By.XPATH, "//button[contains(text(),'Comment')]")
submit_button.click()
break
driver.close()
Traceback (most recent call last):
File "C:\Users\vedant\PycharmProjects\HelloWorld\main.py", line 36, in <module>
comment_box = driver.find_element(By.TAG_NAME, "textarea")
File "C:\Users\vedant\PycharmProjects\HelloWorld\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 861, in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
File "C:\Users\vedant\PycharmProjects\HelloWorld\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "C:\Users\vedant\PycharmProjects\HelloWorld\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"tag name","selector":"textarea"}