Skip to content
Snippets Groups Projects
Commit 69d35044 authored by Samuel Junesjö's avatar Samuel Junesjö
Browse files

Patched dissapearing title bug

parent a41e954b
No related branches found
No related tags found
No related merge requests found
......@@ -83,8 +83,8 @@ def scraper(urllist):
try:
WebDriverWait(driver=driver, timeout=60, poll_frequency = 5).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '[role="article"]')))
driver.execute_script("window.scrollTo(0, 1500)")
driver.execute_script("window.scrollTo(0, 2500)")
time.sleep(5)
WebDriverWait(driver=driver, timeout=60).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '[role="article"]')))
CommentSections = driver.find_elements(by=By.PARTIAL_LINK_TEXT, value=" Comment")
......@@ -168,7 +168,6 @@ def scraper(urllist):
elif "hr" in Date:
HourShift = int(re.sub(" hr.*", "", Date))
PostHour = datetime.datetime.now() - timedelta(hours=HourShift, minutes=0)
print(PostHour)
CoarseDate = PostHour.replace(year=datetime.date.today().year).strftime("%Y-%m-%d-%H:%M")
elif "Today" in Date:
CoarseDate = datetime.datetime.strptime(Date, "Today at %I:%M %p")
......@@ -238,7 +237,9 @@ def postformatter(pagebunch):
if ext == "jpeg":
ext = "jpg"
CheckedImagePath = f"{ImagePath}.{ext}"
trustedImagePaths = []
if CheckedImagePath.rsplit("/", 1)[-1] in os.listdir("html/images"):
trustedImagePaths.append(CheckedImagePath)
os.remove(f"html/{ImagePath}")
print(f"{CheckedImagePath} exists, removing {ImagePath}")
else:
......@@ -258,9 +259,12 @@ def postformatter(pagebunch):
heuristicHashMatch = heuristicHashMatch.encode('utf-8')
hashedPost = hashlib.sha256(heuristicHashMatch).hexdigest()
print(hashedPost)
for i in ImagePaths[1:]:
postString += f" \n![Image]({i})\n"
if ImagePaths:
for i in ImagePaths[1:]:
postString += f" \n![Image]({i})\n"
else:
for i in trustedImagePaths[1:]:
postString += f" \n![Image]({i})\n"
postString = re.sub("(?<=.)\n(?=.)", "<br />", postString)
for text, link in post[3].items():
......@@ -293,6 +297,7 @@ def postformatter(pagebunch):
postString = f"![Profile Picture]({ImagePaths[0]}) ## {TitleDate} \n {postString}"
except:
print("ImagePaths empty")
postString = f"![Profile Picture]({trustedImagePaths[0]}) ## {TitleDate} \n {postString}"
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment