Akashdeep Dhar. t0xic0der
The following snippet of Python code uses Selenium Webdriver and JSON to scrape through the issues available at Pagure and copies them into a dictionary. The same dictionary is then parsed into a JSON string and then written to a file.
from selenium import webdriver
import json
def getissue(link:str, brws:webdriver):
brws.get(link)
rowelist = brws.find_elements_by_css_selector("div.issuerow")
issulist, issuqant = [], 0
for roweindx in rowelist:
issulist.append({
"issuqant": str(roweindx.find_element_by_css_selector("span.text-success.font-weight-bold").get_attribute("innerHTML")).strip(),
"issuname": str(roweindx.find_element_by_css_selector("a.notblue").get_attribute("innerHTML")).strip(),
"issulink": str(roweindx.find_element_by_css_selector("a.notblue").get_attribute("href")).strip(),
"issutags": [str(jndx.get_attribute("innerHTML")).strip() for jndx in roweindx.find_elements_by_css_selector("a.badge")]
})
issuqant += 1
return issuqant, issulist
def mainfunc():
print("ISSUE TRANSFERENCE")
link = "https://pagure.io/fedora-join/Fedora-Join/issues"
brws = webdriver.Chrome(executable_path="/home/t0xic0der/Projects/transference/chromedriver")
rslt = getissue(link, brws)
open("issulist.json", "w").write(json.dumps(rslt[1]))
print(rslt[0], "issues were transferred to 'issulist.json'")
mainfunc()
The further actions would include using the GitHub CLI which very recently came out Beta to automate creation of issues in the given repository on GitHub. Do make sure to setup a push mirror for the same before that.