Skip to content

Bug #3308

Closed
Closed
Bug#3308
@Prodigysec

Description

@Prodigysec

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
 \ P y t h o n 3 7 \ p y t h o n . e x e ' Space ' c : \ U s e r s \ H P \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 2 . 4 . 1 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Space ' 6 1 5 2 3 ' Space ' - - ' Space ' c : \ U s e r s \ H P \ D e s k t o p \ P Y T H O N \ P y B a s i c s P r a c t i c a l \ W E B \ s c r a p e E X C 1 . p y ' Space Enter


Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.      
Parameter name: top
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)    
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Screenshot

N/A

Environment data

PS Version: 5.1.19041.1645
PS HostName: ConsoleHost
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.320 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 3000

Steps to reproduce

#1. Write a script that grabs the full HTML from the page
#2. Use the string .find() method to display the text following “Name:” and “Favorite Color:” (not including

any leading spaces or trailing HTML tags that might appear on the same line).

3. Repeat the previous exercise using regular expressions. The end of each pattern

should be a “<” (the start of an HTML tag) or a newline character, and you should remove

any extra spaces or newline characters from the resulting text using the string .strip() method.

import re
from urllib.request import urlopen

url = "http://olympus.realpython.org/profiles/dionysus"
page = urlopen(url)
html = page.read().decode("utf-8")

print(html)
print("+++++")

start_heading = "

"
end_heading = "

"
start_index = html.find(start_heading) + len(start_heading) + len("Name: ")
end_index = html.find(end_heading)

print(html[start_index:end_index])
print("+++++")
f_Color_start = "
"
f_Color_end = ""
start_index = html.find("Favorite Color") + len("Favorite Color: ")
end_index = html.find(f_Color_end)

print(html[start_index:end_index])

#Using re
pattern = "<h2.?>.?"
match_results = re.search(pattern,html,re.IGNORECASE)
name = match_results.group()
name = re.sub("<.*?>", "",name)

name = re.sub("Name: ","",name)

print(name)

pattern = "
\n.?"
match_result = re.search(pattern,html,re.IGNORECASE)
print(match_result)
#name = match_result.group()
name = re.sub("<.
?>", "",name)

name = re.sub("Name: ","",name)

print(name)

Expected behavior

<TITLE >Profile: Dionysus</title / >

Name: Dionysus



Hometown: Mount Olympus

Favorite animal: Leopard

Favorite Color: Wine

+++++
Dionysus
+++++
Wine

Name: Dionysus
None
Name: Dionysus

Actual behavior

Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Last 200 Keys:
\ P y t h o n 3 7 \ p y t h o n . e x e ' Space ' c : \ U s e r s \ H P \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 2 . 4 . 1 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Space ' 6 1 5 2 3 ' Space ' - - ' Space ' c : \ U s e r s \ H P \ D e s k t o p \ P Y T H O N \ P y B a s i c s P r a c t i c a l \ W E B \ s c r a p e E X C 1 . p y ' Space Enter

Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -1.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions