From f20897636a42cb538af9398bec766bda9f1019f4 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Mon, 3 Aug 2026 08:32:05 +0100 Subject: [PATCH] fix: correlate step pictures correctly and decode unicode titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wikiHow moved step images out of their `div.step` and dropped the `data-src` attribute, so `_parse_pictures` always produced empty picture URLs and, on pages with more images than steps, could raise an uncaught IndexError (masked as a generic ParseError with the original cause discarded). Pictures are now matched to their step via the `Step-` token in the image href, which is the article-global step number and lines up with the flat, DOM-ordered steps list. Also fixes non-ASCII article titles being left percent-encoded (e.g. "C%C3%A9lulas" instead of "Células"), missing URL-encoding of special characters in search queries, and preserves the original exception as __cause__ when a page fails to parse. Adds pytest coverage against recorded real wikiHow fixtures (no network access during tests), an example for the picture field, a minimal pyproject.toml build-system section, and a [test] extra in setup.py. Co-Authored-By: Claude Sonnet 5 --- .gitignore | 7 + README.md | 8 + examples/step_pictures.py | 7 + pyproject.toml | 3 + pywikihow/__init__.py | 38 +- setup.py | 1 + tests/__init__.py | 0 tests/fixtures/contar_celulas_pt.html | 985 ++++++++ tests/fixtures/fold_fitted_sheet.html | 2544 +++++++++++++++++++++ tests/fixtures/not_found.html | 412 ++++ tests/fixtures/search_bitcoin.html | 969 ++++++++ tests/fixtures/tie_a_tie.html | 3002 +++++++++++++++++++++++++ tests/test_pywikihow.py | 202 ++ 13 files changed, 8163 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 examples/step_pictures.py create mode 100644 pyproject.toml create mode 100644 tests/__init__.py create mode 100644 tests/fixtures/contar_celulas_pt.html create mode 100644 tests/fixtures/fold_fitted_sheet.html create mode 100644 tests/fixtures/not_found.html create mode 100644 tests/fixtures/search_bitcoin.html create mode 100644 tests/fixtures/tie_a_tie.html create mode 100644 tests/test_pywikihow.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..750b922 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +__pycache__/ +*.pyc +*.egg-info/ +.venv/ +.pytest_cache/ +build/ +dist/ diff --git a/README.md b/README.md index a5a7539..3719680 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,14 @@ Some articles divide their steps into parts. The `part` field of a step holds th print(first_step.part) ``` +Not every step has an illustration. When one exists, the `picture` field holds its URL; otherwise it is `None`. + +```python +for step in how_to.steps: + if step.picture: + print(step.number, step.picture) +``` + ### ToDo - Add parser for tips diff --git a/examples/step_pictures.py b/examples/step_pictures.py new file mode 100644 index 0000000..6fd1cc3 --- /dev/null +++ b/examples/step_pictures.py @@ -0,0 +1,7 @@ +from pywikihow import HowTo + +how_to = HowTo("https://www.wikihow.com/Tie-a-Tie") + +for step in how_to.steps: + if step.picture: + print(step.number, step.summary, "->", step.picture) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b2fcc25 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=64"] +build-backend = "setuptools.build_meta" diff --git a/pywikihow/__init__.py b/pywikihow/__init__.py index 2519581..2cadf6a 100644 --- a/pywikihow/__init__.py +++ b/pywikihow/__init__.py @@ -1,4 +1,6 @@ import re +from urllib.parse import quote, unquote + import bs4 from pywikihow.exceptions import ParseError, UnsupportedLanguage from datetime import timedelta @@ -131,7 +133,7 @@ def _parse_title(self, soup): self._url = html.find("a").get("href") if not self._url.startswith("http"): self._url = "http://" + self._url - self._title = self._url.split("/")[-1].replace("-", " ") + self._title = unquote(self._url.split("/")[-1]).replace("-", " ") def _parse_intro(self, soup): # get article intro/summary @@ -183,18 +185,24 @@ def _parse_steps(self, soup): self._steps.append(step) def _parse_pictures(self, soup): - # get step pic - count = 0 - for html in soup.find_all("a", {"class": "image"}): - # one more ugly blob, nice :D - html = html.find("img") - i = str(html).find("data-src=") - pic = str(html)[i:].replace('data-src="', "") - pic = pic[:pic.find('"')] - - # save in step - self._steps[count]._picture = pic - count += 1 + # Step pictures are not nested inside their "step" div. Each one is + # identified by a "Step-" token in its href, where is the + # 1-based step number counting across the whole article (not reset + # per part), which lines up with the flat, DOM-ordered self._steps + # list. The intro/summary image has no such token and is skipped. + for link in soup.find_all("a", {"class": "image"}): + match = re.search(r"Step-(\d+)", link.get("href", "")) + if not match: + continue + index = int(match.group(1)) - 1 + if not 0 <= index < len(self._steps): + continue + img = link.find("img") + if not img: + continue + pic = img.get("data-src") or img.get("src") + if pic: + self._steps[index]._picture = pic def _parse(self): try: @@ -206,7 +214,7 @@ def _parse(self): self._parse_pictures(soup) self._parsed = True except Exception as e: - raise ParseError + raise ParseError(str(e)) from e def as_dict(self): return { @@ -254,7 +262,7 @@ def search(search_term, max_results=-1, lang="en"): if lang not in WikiHow.lang2url: raise UnsupportedLanguage search_url = WikiHow.lang2url[lang] + \ - "wikiHowTo?search=" + search_term.replace(" ", "+") + "wikiHowTo?search=" + quote(search_term) html = get_html(search_url) soup = bs4.BeautifulSoup(html, 'html.parser').find_all('a', attrs={ 'class': "result_link"}) diff --git a/setup.py b/setup.py index 1603ccf..c16f5c3 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def get_description(): packages=['pywikihow'], url='https://github.com/LeMetadatarr/PyWikiHow', install_requires=required('requirements.txt'), + extras_require={'test': ['pytest']}, license='MIT', author='jarbasai', author_email='jarbasai@mailfence.com', diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixtures/contar_celulas_pt.html b/tests/fixtures/contar_celulas_pt.html new file mode 100644 index 0000000..a8fadf6 --- /dev/null +++ b/tests/fixtures/contar_celulas_pt.html @@ -0,0 +1,985 @@ + + + + +Como contar células no Google Planilhas no Windows ou Mac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Skip to Content
+
+
+
+ + + PDF download + Baixe em PDF + + + + + + PDF download + Baixe em PDF + + + + + + +
+

Este artigo vai ensinar você a usar a função "CONT.SE" no Google Planilhas para exibir o número de células em um determinado intervalo. +

+
+
+
+ +
+
+
+
+

+
+Passos +

+ + + PDF download + Baixe em PDF + + +
+
+
    +
  1. + +
    +Acesse o site https://sheets.google.com em um navegador de internet. Caso sua conta do Google não esteja aberta, siga as instruções na tela para acessá-la. + +
    +
    +
    +
  2. +
  3. + +
    + Se preferir criar uma planilha nova, clique na caixa com um "+" no canto superior esquerdo da lista. +
    +
    +
    +
  4. +
  5. + +
    + Inseriremos a fórmula nela. +
    +
    +
    +
  6. +
  7. + +
    + +
    +
    +
    +
  8. +
  9. + +
    + Para fazê-lo, clique e arraste o cursor do mouse sobre todo o intervalo. Em seguida, o intervalo será adicionado à fórmula "CONT.SE". +
    • Também é possível digitar o intervalo manualmente no seguinte formato: B2:C4.
    +
    +
    +
    +
  10. +
  11. + +
    + Para contar cada célula selecionada, independentemente de seu valor, pule este passo. Caso contrário, digite uma , e depois o critério entre aspas (""). Veja alguns exemplos:[1] + +
      +
    • Para contar apenas as células B2:C4 com valores acima de 50, a fórmula será =CONT.SE (B2:C4,">50".
    • +
    • Para contar apenas as células B2:C4 com o valor "Sim", a fórmula será =CONT.SE(B2:C4,"Sim".
    • +
    +
    +
    +
    +
  12. +
  13. + +
    + Em seguida, ela será encerrada. +
      +
    • Exemplo sem critério: =CONT.SE(B2:C4) +
    • +
    • Exemplo com critério: =CONT.SE(B2:C4,">50") +
    • +
    +
    +
    +
    +
  14. +
  15. + +
    + Agora, a contagem das células selecionadas que atenderem ao critério (caso aplicável) aparecerão na célula. +
    +
    +
    +
    +
    Publicidade
    + +
  16. +
+
+
+
+
+ +
+
+ + + + + + +
+
+
+
+
+
+

WikiHows Relacionados

+
+
+Abrir o Prompt de Comando no Windows5 Formas Simples de Abrir o Prompt de Comando no Windows +
+
+Selecionar TudoSelecionar Tudo +
+
+
+Fechar Janelas no ComputadorFechar Janelas no Computador +
+
+Apagar os Arquivos Temporários e os Arquivos Prefetch no WindowsApagar os Arquivos Temporários e os Arquivos Prefetch no Windows +
+
+Digitar o Símbolo do EuroDigitar o Símbolo do Euro +
+
+Ligar um ComputadorLigar um Computador +
+
+Digitar o Símbolo de Marca RegistradaDigitar o Símbolo de Marca Registrada +
+
+Digitar Acentos nas PalavrasDigitar Acentos nas Palavras +
+
+Fazer o Símbolo de Coração Utilizando o ComputadorFazer o Símbolo de Coração Utilizando o Computador +
+
+Executar o Prompt de Comando como Administrador no Windows Executar o Prompt de Comando como Administrador no Windows: 4 Passos Simples +
+
+Encontrar ou Mudar o Administrador do Meu Computador Encontrar ou Mudar o Administrador de um Computador, do Mac e do Chromebook +
+
+Colar Usando o Teclado4 Formas de Colar Textos Usando Atalhos do Teclado +
+
+Abrir Arquivos EXEAbrir Arquivos EXE +
+
+Copiar e Colar um LinkCopiar e Colar um Link +
+
+
+
+
Publicidade
+
+
+
+ +
+ +
+
+

Sobre este guia wikiHow

+
+
+ +
+ +
+
+ +
+ +
Equipe wikiHow
+ + + + +
+
+
+ Coescrito por : +
+ +
Redação do wikiHow
+
+
+ +
+
+ Este artigo foi escrito em parceria com nossa equipe treinada de editores e pesquisadores que validaram sua precisão e abrangência.

O wikiHow possui uma Equipe de Gerenciamento de Conteúdo que monitora cuidadosamente o trabalho de nossos editores para garantir que todo artigo atinja nossos padrões de qualidade. Este artigo foi visualizado 60 605 vezes. +
+ + +
+ Categorias: Informática Básica +
+ +
+
+ +
+ + + + +
Esta página foi acessada 60 605 vezes.
+
+
+
+
+

Este artigo foi útil?

+
+ + +
+
+
+
+
+
Publicidade
+ +
+


+
+ + + + + + + + + + + +
-
-
+ + + + \ No newline at end of file diff --git a/tests/fixtures/fold_fitted_sheet.html b/tests/fixtures/fold_fitted_sheet.html new file mode 100644 index 0000000..c0ac4fb --- /dev/null +++ b/tests/fixtures/fold_fitted_sheet.html @@ -0,0 +1,2544 @@ + + + + +How to Fold a Fitted Sheet: Full Guide with Pictures + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Skip to Content
+
+
+
+ + + PDF download + Download Article + + +
Cleaning expert Raymond Chiu walks through getting neat folds on fitted sheets
+ + + + PDF download + Download Article + + + +
+ +
+ ARTICLE +
+
+
+ VIDEO + +
+ +
+ + +
+ +

If you’re tired of fitted sheets looking sloppy when you fold them, we’re here to help. The elastic bands help the sheets stay on your bed, but make it difficult to get nice, clean folds. Luckily, you can still fold the sheets into neat rectangles or rolls to keep your linen closet organized. wikiHow spoke with a cleaning expert for advice on getting the perfect folds on your fitted sheets and your other bed sheets. +

+
+
+
+ +
+
+ +
+ + +
+ +
+
+
+
+
+
Section 1 of 3:
+

How to Fold a Fitted Sheet into a Neat Rectangle +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + To start, turn the fitted sheet inside-out so the rough hems are visible. Chiu says to “lay the [fitted sheet] flat with the elastic corners facing up.”[1] + Make sure to keep one of the long edges in front of you. +
      +
    • Most newer fitted sheets have tags on the inside marking the long and short sides so you don’t get confused.
    • +
    • Try to fold sheets as soon as they come out of the dryer so they don’t get wrinkled. +
    • +
    + +
    +
    +

    Meet the wikiHow Expert

    +

    Raymond Chiu is a house cleaning professional and the owner of Maid Sailors Cleaning Service in New York City since 2014.

    +
    +
    +
    +
  2. +
  3. + +
    + Slip your hands into the corners closest to you so the elastic edge faces your body. Bring your right hand and corner over to your left hand so the seams line up with each other. Then, Chiu says to fold the 2 corners together and flip the right corner right-side-out so it wraps over the corner in your left hand.[2] + +
    • Keep your left hand inside the corner and shake out the fitted sheet to smooth out any wrinkles.
    +
    +
    +
    +
    Advertisement
    +
    +
  4. +
  5. + +
    + Run your right hand down the elastic edge of the fitted sheet until you reach the third corner. Bring the corner up and tuck it inside the pocket made by the first 2 corners. Then, repeat the process to tuck and fold the final corner.[3] + +
    • When you finish, your fitted sheet will be about a quarter of the size and look like a square with the elastic forming an L-shape.
    +
    +
    +
    +
  6. +
  7. + +
    + Lay the partially folded fitted sheet flat on a table so the elastic is face-up. Then, Chiu advises to fold the fitted sheet into thirds by taking the outer edges and folding them in toward the center. He notes to smooth out any wrinkles as you go to keep the sheet looking neat.[4] + +
      +
    • When you’re finished, the fitted sheet will look like a long, narrow rectangle with all of the elastic edges hidden on the inside.
    • +
    • If you don't have a table that's big enough, spread the sheet out on your bed or on the floor if you have recently cleaned.
    • +
    +
    +
    +
    +
  8. +
  9. + +
    + Depending on how small you want to make your fitted sheet, take the short edge of the rectangle and fold it toward the other side. You can fold the sheet in half or in thirds for a more compact fold.[5] + +
      +
    • If you have a king-size bed, you may need to fold the long rectangle into quarters rather than thirds. To do that, just fold the sheet in half lengthwise, then in half again.
    • +
    • Smooth out the edges when you’re finished to prevent the sheet from getting wrinkled when you store it.
    • +
    • Keep the sheet in a drawer or linen closet when you’re finished.
    • +
    +
    +
    +
    + +
  10. +
    +
    Advertisement
    + +
+
+
+
+ +
+
+
+
+
Section 2 of 3:
+

How to Roll a Fitted Sheet for a Small Space +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + Spread your fitted sheet upside-down on a large table or your bed so the elastic bands are face up. Smooth out the wrinkles as best as you can so the fitted sheet looks neat. +
    +
    +
    +
  2. +
  3. + +
    + With one of the long edges facing you, grab the 2 corners closest to you and fold them in just past the center. Then, take the 2 corners furthest from you and fold them to the center so they overlap the first fold.[6] + +
      +
    • After this step, your fitted sheet will look like a long, narrow rectangle.
    • +
    • Smooth out the sheet as you go to prevent it from wrinkling.
    • +
    +
    +
    +
    +
  4. +
  5. + +
    + Take one short end of the rectangle and fold it toward the opposite side. Run your hand over the creases to flatten them out. +
    +
    +
    +
  6. +
  7. + +
    + Start from the side with the loose ends, and tightly roll it up toward the other end. Once your sheet is all rolled, set it on a shelf in a linen closet or keep it organized in a drawer or basket.[7] + + +
    +
    +
    +
  8. +
    +
    Advertisement
    + +
+
+
+
+ +
+
+
+
+
Section 3 of 3:
+

How to Fold Other Bed Sheets +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + Spread the top sheet out so it’s flat on your bed or large table. Take 2 of the corners and bring them together to make your first fold. Smooth out any wrinkles or creases before folding the top sheet in half again so the opposite sides line up. Keep folding the top sheet in half until you have a neat square or rectangle.[8] + +
      +
    • Alternatively, after you fold your sheet in half twice, bring the long edges toward the center to fold it in thirds to make a long triangle. Then, fold it in thirds again to make a smaller rectangle.
    • +
    • Ask someone else to help you fold the top sheet if you’re having trouble lining up the edges on your own.
    • +
    +
    +
    +
    +
  2. +
  3. + +
    + Lay your pillowcase flat on a surface, and fold the long edges toward the center to make a long rectangle. Smooth out the wrinkles, and then fold the rectangle in half or in thirds, depending on how small and compact you need your pillowcase for storage.[9] + +
    • Alternatively, place your folded fitted sheet and top sheet inside a matching pillowcase for an easy way to keep them together in your linen closet!
    +
    +
    1. And if the steps above have been helpful, be sure to download this article as a PDF so you can print, read, or reference it any time.
    + +
    + +
    +
    +
    +
    +
    +
  4. +
    +
    Advertisement
    + +
+
+
+
+
+ + +
+
+
+

+ Join the Discussion... +

+
+
+ + +
+ + + + + +
+ +
+
+ WikiGladeReader229 +
+ +
+ +
+ +
+ WikiGladeReader229 + + + + +
+ +
+
Every time I try to fold up fitted sheets, they just look sloppy and don't fit well with the other sheets in my closet. I just want them to be neatly folded so stay wrinkle-free and organized. Please, any tips would be a huge lifesaver.
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+ Raymond Chiu +
+ +
+ +
+ +
+ Raymond Chiu + +
House Cleaning Professional + + +
+ +
+
The trick to fold a fitted sheet neatly is start by laying it flat with the elastic corners facing up. Then, fold the two corners together, tucking one inside of the other. After that, fold the sheet into thirds and smooth out any wrinkles to keep it neat.
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ WikiBandicootWalker330 +
+ +
+ +
+ + + +
+
Here's an organization tip—store your fitted sheet inside the matching pillowcase! Keeps everything neat and tidy and in one place :) Plus no one will be able to see how poorly you've folded your fitted sheet haha.
+ +
+ +
+ +
+
+ +
+
+ + +
+ +
+ +
+
+
+
+

+ + Expert Q&A + +

+
+
+
+
+
+
Search
+ +
+ Add New Question +
    +
  • +
    + +
    +
    Question
    +
    How do I perfectly put a fitted sheet on a mattress like in a hotel?
    + + + +
    +
    +
    + +
    + + Raymond Chiu + + +
    + + Raymond Chiu + + + +
    + + House Cleaning Professional +
    +Raymond Chiu is the owner of Maid Sailors Cleaning Service, offering affordable residential and office cleaning services. Since its founding in 2014 in New York City, Maid Sailors has expanded to several cities, including Boston, Chicago, and Austin. The company has earned a reputation as one of the most reliable and best cleaning services in the industry. + + +
    + + Raymond Chiu + + +
    + +
    House Cleaning Professional
    + + +
    Expert Answer
    + +
    +
    + +
    + Start with placing the fitted sheet loosely on the top of your mattress so that the corners are aligned in a way that they follow the corners of your bed. Tuck and pull the sheets tight around the corners at the edges to remove all the wrinkles. Once all corners are fitted, add your blanket or comforter on top. Lastly, tuck the bottom of the blanket under the mattress for a more polished hotel style look, or you could let it drape loosely for a more relaxed style. +
    + +
    +
    +
  • +
  • +
    + +
    +
    Question
    +
    Can you tell me what a crisp sheet is?
    + + + +
    +
    +
    + +
    + +
    + + + wikiHow Staff Editor + +
    + +
    + wikiHow Staff Editor
    + Staff Answer +
    + +This answer was written by one of our trained team of researchers who validated it for accuracy and comprehensiveness. +
    + + +
    + + + wikiHow Staff Editor + +
    + +
    + +
    wikiHow Staff Editor
    + +
    Staff Answer
    + +
    +
    + +
    + A crisp sheet is one that's fresh and clean, with sharp creases. It may also refer to sheets made of fabrics like high-thread-count cotton, as opposed to softer sheets like flannel or satin. +
    + +
    +
    +
  • +
  • +
    + +
    +
    Question
    +
    How do I fold a flat king sheet?
    + + + +
    +
    + + +
    + + +
    + + +
    + + + Community Answer + +
    + +
    + +
    + +
    Community Answer
    + +
    +
    + +
    + The same as you would fold any other flat sheet, towel, etc. Keep matching up corners and folding until it is a size you like. +
    + +
    +
    +
  • +
+ + See more answers +
+
+
+ + + +
Ask a Question
+
+ +
200 characters left
+ +
Include your email address to get a message when this question is answered.
+ Submit +
+ + +
+
+
    +
+
+
+
+
+
    +
+
+
+ + + + + + + + + + + + + + + + + +
+
+
+
Advertisement
+ +
+ + +
+
+
+

+
+Video +

+Read Video Transcript +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+

+ Tips +

+
+
+
+
+

Tips from our Readers +

+ +
    +
  • If your bedding came in a plastic zipper bag, reuse the original bag to store sheets and pillowcases together. This keeps them organized and helps protect them from dust. Keeping the original product insert in the inner pocket also identifies the size, fabric content, vendor, etc. for future reference. + + +
  • +
+
+
+ +
+
Submit a Tip +
All tip submissions are carefully reviewed before being published
+
+ +
+ Name +
Please provide your name and last initial
+
+ +
+ + + Submit + +
+
+ +
+ Thanks for submitting a tip for review! +
+
+
+ +
+
+ + + +
+
+ +
+
+ + +
+
+ + + + + + + +
+
+
+
+
+ +
+

You Might Also Like

+
+
+Tips for Folding a Fitted SheetTips for folding a fitted sheet +
+
+Make a Hospital Corner Fold Hospital or Military Corners on Your Bed +
+
+
+ Sew a Fitted Sheet for Beginners +
+
+Make Your Bed Properly Make Your Bed +
+
+Make a Hotel Bed Make a Hotel Bed: Simple Steps +
+
+ Fold Boxers & Boxer Briefs to Save Space: 7 Easy Ways +
+
+Fold Clothes Fast Fold Clothes in Seconds: Quick & Easy Guide +
+
+Make a Bed Neatly Neatly Make Your Bed the Right Way +
+
+Fold Underwear Fold Underwear: 7 Space-Saving Storage Methods +
+
+Fold a BlanketFold a Blanket +
+
+Fold Long Sleeve ShirtsFold Long Sleeve Shirts +
+
+Fold a ShirtFold a Shirt +
+
+Prevent Sheets from Slipping Off a BedPrevent Sheets from Slipping Off a Bed +
+
+Clean Your Room Quickly and Efficiently13 Quick & Efficient Hacks for Cleaning Your Room +
+
+
+
+
+
Advertisement
+ +
+
+
+
+

+
+Expert Interview +

+
+
+ +

Thanks for reading our article! If you’d like to learn more about cleaning, check out our in-depth interview with Raymond Chiu. +

+
+
+
+
+
+

+
+References +

+
    +
  1. +↑ Raymond Chiu. House Cleaning Professional. Expert Interview +
  2. +
  3. +↑ Raymond Chiu. House Cleaning Professional. Expert Interview +
  4. +
  5. +↑ https://youtu.be/_Z5k9nWcuFc?t=52 +
  6. +
  7. +↑ Raymond Chiu. House Cleaning Professional. Expert Interview +
  8. +
  9. +↑ https://www.consumerreports.org/sheets/how-to-fold-a-fitted-sheet/ +
  10. +
  11. +↑ https://youtu.be/iCOtOdLjptc?t=39 +
  12. +
  13. +↑ https://youtu.be/iCOtOdLjptc?t=59 +
  14. +
  15. +↑ https://youtu.be/bIH-bXU_uA4?t=31 +
  16. +
  17. +↑ https://youtu.be/UdUd4wLkyQA?t=5 +
  18. +
+
+
+ +
+
+

About This Article

+
+
+ +
+ +
+
+ +
+ +
Raymond Chiu
+ + + + +
+
+
+ Co-authored by: +
+ +
House Cleaning Professional
+
+
+ +
+
+ This article was co-authored by Raymond Chiu and by wikiHow staff writer, Hunter Rising. Raymond Chiu is the owner of Maid Sailors Cleaning Service, offering affordable residential and office cleaning services. Since its founding in 2014 in New York City, Maid Sailors has expanded to several cities, including Boston, Chicago, and Austin. The company has earned a reputation as one of the most reliable and best cleaning services in the industry. This article has been viewed 7,076,666 times. +
+ + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How helpful is this?
+
+ + +
+ +
+
+ Co-authors: 38 +
+
+ Updated: July 21, 2026 +
+
+ Views: 7,076,666 +
+
+ + +
+ Categories: Featured Articles | Bed Sheets +
+ +
+
+ +
+
+Article SummaryX

To fold a fitted sheet, hold it lengthwise and inside-out. Put your hands inside the top two corners of the sheet. Next, bring your palms together. Fold the corner in your right hand over the corner in your left hand. Change hands and place your right hand in the corner where your left hand was. Now, straighten the edge of the sheet with your left hand until you reach the opposite corner. Then, put your left hand inside that corner. Bring your hands together again and fold the corner in your right hand over the corner in your left hand. Straighten the edges of the sheet. Now, lay the sheet down with the folded edges up. Fold the top side in so the sheet is rectangular. Fold the sheet into thirds lengthwise, then into thirds horizontally.

+Did this summary help you?
+ +
+

+
+ + + + +
Thanks to all authors for creating a page that has been read 7,076,666 times.
+
+
+
+
+ +
+
+

Reader Success Stories

+
+
+ +
+ +
    +
  • + +
    + + + + + + Andrew Huggett + + +
    +

    Andrew Huggett

    +

    Aug 11, 2017

    +
    +
    + +
    + "After trying to follow the YouTube video on this which seems to 'skip' a step & return when the sheet..." more +
    + + + +
  • + +
+ + + + Share your story + +
+
+
+
+ +
+

Did this article help you?

+
+ + +
+
+
+
+
+
Advertisement
+ +
+


+
+ +
+
+ +
+

wikiHow Tech Help Pro:

+

Level up your tech skills and stay ahead of the curve

+ + +
+
+
+ + + + + + + + + + +
+ X +
+
+

+

+
+
+ +
+
+
+ +
-
-
+ + + + + \ No newline at end of file diff --git a/tests/fixtures/not_found.html b/tests/fixtures/not_found.html new file mode 100644 index 0000000..193d064 --- /dev/null +++ b/tests/fixtures/not_found.html @@ -0,0 +1,412 @@ + + + + +This page is not available - wikiHow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Skip to Content
+
+

What can you do now?
+

+
  • Go to our Main Page to see a regularly updated list of some of the best articles on wikiHow.
  • +
  • Do you want to write about this topic? Learn how to write a new article on wikiHow.
  • +
  • Use the search box below to search for anything you'd like to learn to do.
+
+ +
+
+ + + + + + +
+
+
+


+
+ + + + + + + + + + + +
-
-
+ + + + \ No newline at end of file diff --git a/tests/fixtures/search_bitcoin.html b/tests/fixtures/search_bitcoin.html new file mode 100644 index 0000000..985ec7d --- /dev/null +++ b/tests/fixtures/search_bitcoin.html @@ -0,0 +1,969 @@ + + + + +Search for “how to buy bitcoin” - wikihow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Skip to Content
+ + + + + + + + +
+ +
+ + + +
+
+ + +
+
+
How to Buy Bitcoins: Easy & Trustworthy Options + Tips
+
    +
  • 624,046 views
  • +
  • + Updated + 4 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + HOW TO +
+
+
Category: Bitcoin
+
    +
  • 24,177 views
  • +
  • + Updated + 9 months ago +
  • + +
+ +
+
+
+ + +
+
+ + +
+
+
How to Send Bitcoins
+
    +
  • 257,896 views
  • +
  • + Updated + 1 year ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+
+ +
+
+ + +
+
+
How to Mine Bitcoin
+
    +
  • 1,246,145 views
  • +
  • + Updated + 6 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Use Bitcoin
+
    +
  • 550,379 views
  • +
  • + Updated + 5 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
A Quick-Start Guide to Buying Bitcoin (BTC)
+
    +
  • 194,940 views
  • +
  • + Updated + 1 year ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
Is Bitcoin Halal or Haram? What Muslim Scholars Say
+
    +
  • 1,101 views
  • +
  • + Updated + 6 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Convert Bitcoins to Dollars
+
    +
  • 375,703 views
  • +
  • + Updated + 2 years ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Create an Online Bitcoin Wallet
+
    +
  • 516,275 views
  • +
  • + Updated + 1 year ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Verify Bitcoin on Cash App: Quick Step-by-Step Guide
+
    +
  • 25,436 views
  • +
  • + Updated + 9 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Store Bitcoin with a Paper Wallet
+
    +
  • 68,164 views
  • +
  • + Updated + 2 years ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Buy a Home: Everything You Need to Know
+
    +
  • 1,854,662 views
  • +
  • + Updated + 5 months ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Buy Stocks
+
    +
  • 4,072,561 views
  • +
  • + Updated + 1 week ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How and Where to Buy Condoms
+
    +
  • 1,173,918 views
  • +
  • + Updated + 2 years ago +
  • +
  • Expert Co-Authored
  • +
+ +
+
+
+ + +
+
+ + +
+
+
How to Buy Robux: 3 Easy Ways
+
    +
  • 636,714 views
  • +
  • + Updated + 2 years ago +
  • + +
+ +
+
+
+ +
+
+ + + + +
+
+


+
+ + + + + + + + + + + +
-
-
+ + + + \ No newline at end of file diff --git a/tests/fixtures/tie_a_tie.html b/tests/fixtures/tie_a_tie.html new file mode 100644 index 0000000..a10aaa9 --- /dev/null +++ b/tests/fixtures/tie_a_tie.html @@ -0,0 +1,3002 @@ + + + + +4 Ways to Tie a Tie - wikiHow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Skip to Content
+
+
+
+ + + PDF download + Download Article + + + + + + PDF download + Download Article + +
+
+
+ + + +
+
+
+ +
+ +
+ ARTICLE +
+
+
+ VIDEO + +
+ +
+ + +
+ +

Have you graduated beyond the clip-on tie? Beginning with these helpful instructions, a sharp-looking tie, a mirror, and some patience, you can become an expert in tying your own fashionable knot. You have several options available, from the versatile Four-in-Hand Knot and classic Windsor, to the basic yet formal Pratt knot and stylishly neat half Windsor. +

+

If you're helping someone else put on a tie, see this article for instructions from that perspective. +

+
+
+
+ +
+
+
+
+
+

+
+The Easiest Way to Tie a Tie (Four-in-Hand) +

+
+ Download Image +
+ + +
+
+ + +
+ +
+
+
+
Method 1 +
+
+
+
Method 1 of 4:
+

Using the Tupac Method (Four-in-Hand Knot) +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + With your collar up and your shirt fully buttoned, place the tie around your shoulders. Hang the wider end of the tie on your right side, with the narrow end about 12 inches (30 cm) higher on the left.[1] + + + +
    +

    Tip: Avoid spread collars with this small, asymmetric knot.

    +
    +
    +
  2. +
  3. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Bring the wide end to the left side of your body, over the narrow end. Hold the two pieces of cloth together with your left hand, near your neck. +
    +
    +
    +
    Advertisement
    +
    +
  4. +
  5. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Let go with your right hand. Tuck it underneath the narrow end, grab the wide end, and pull it back through to your right side. +
    +
    +
    +
  6. +
  7. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Cross it over the narrow end one more time, at the same point where your left hand is holding the knot together. +
    +

    Note: The front of the tie should be facing forward again (so the seam is hidden).

    +
    +
    +
  8. +
  9. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Fold the tip of the wide end under itself and pull up through the neck loop.[2] + +
    +
    +
    +
  10. +
  11. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + You should have a horizontal knot across the front of your tie. Hold this knot open with your finger and carefully insert the wide end. +
    +
    +
    +
  12. +
  13. + +
    + Hold the narrow end and slide the front knot up to tighten the tie. Make sure your tie is straight and the length is appropriate, ideally ending at the top of your belt buckle. + +
    • Squeeze the sides of the knot gently to create a dimple just below it.
    +
    +

    Tip: The four-in-hand knot is a little asymmetrical at the neck. Don't worry about this; it is normal.

    +
    +
    +
  14. +
  15. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + +
    +
    +
    +
  16. +
  17. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + +
    +
    +
    + +
  18. +
    +
    Advertisement
    + +
+
+
+
+ +
+
+
Method 2 +
+
+
+
Method 2 of 4:
+

Tying the Traditional Windsor Knot (Extra Formal) +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    +Put the tie around your neck. Make sure the wider end is on the right, and about 14 inches (36 cm) lower than the thinner side on the left. The Windsor knot uses a lot of cloth, so the lower end should start a bit lower than you would usually position a tie. + +
    +

    Tip: Many consider the large, symmetric Windsor knot the most elegant and formal option. Wear it with a spread or wide spread collar.[3] +

    +
    +
    +
  2. +
  3. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Hold one end in each hand, then pass each of them to the opposite hand. The wide end should now be on your left side.[4] + +
    +
    +
    +
  4. +
  5. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Using your right hand, hold the two ends where they cross near your collar. With your left hand, pull the wide end up through the neck loop from below. +
    +
    +
    +
  6. +
  7. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Rest the wide end back on your chest, to the left of the narrow end. +
    +
    +
    +
  8. +
  9. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Grab the wide end with your right hand and pull it back to the right side of your body, under the narrow end. Hold the knot near your collar in place with your left hand. +
    +
    +
    +
  10. +
  11. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Fold it back over from right to left, so the front side is visible again. +
    +
    +
    +
  12. +
  13. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Bring the wide end back up through the neck loop one last time. +
    +
    +
    +
  14. +
  15. + +
    + Place the wide end through the horizontal knot at the front of the tie. Pull it through. +
    +
    +
    +
  16. +
  17. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Hold the base of the front knot and squeeze gently from the sides. Slowly pull the wide end of the tie to bring the knot closer to the neck. +
    +
    +
    +
  18. +
    +
    Advertisement
    + +
+
+
+
+ +
+
+
Method 3 +
+
+
+
Method 3 of 4:
+

Tying the Pratt Knot (Basic Formal Knot) +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + Unlike most knots, the Pratt knot begins with the tie upside down, so the seam of the tie is facing forward. Hang the wide end of the tie over your right side, and the narrow end over your left side. +
    • This medium size knot suits most collars and builds.
    +
    +
    +
    +
  2. +
  3. + +
    + In a knotted tie, the wide end should just graze the top of your belt buckle.[5] + At the start, however, raise or lower the wide end until it hangs 1–2 inches (2.5–5 cm) below this point. As a rule of thumb, the Pratt knot will lift the wide end by this distance as you tie the knot.[6] + +
    • The narrow end of the tie should be higher than the wide end. It will usually be around belly button level, but this is less important than the wide end's placement.[7] + +
    +
    +
    +
    +
  4. +
  5. + +
    + Move the wide end across your body to the left side, placing it underneath the narrow end. +
    • Do not move the narrow end of the tie for any part of this knot.[8] + Just hold it steady while you use the wide end.
    +
    +
    +
    +
  6. +
  7. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Place the tip on top of the loop, still on your left side. +
    +
    +
    +
  8. +
  9. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Insert the wide end down into the loop from above. Pull it through in the same direction it lay before, on the left. +
    +
    +
    +
  10. +
  11. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + This flips the wide end so the seam is no longer visible. The wide end will extend at an angle off to your right. +
    +
    +
    +
  12. +
  13. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Bring the wide end up to your neck loop again, but this time from below. Pull it through. +
    +
    +
    +
  14. +
  15. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Your last fold created a horizontal loop at the front of your tie. Tuck the wide end through this loop, and pull straight down to tighten. The wide end should now rest in front of the narrow end. +
    +
    +
    +
  16. +
  17. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Pull down on the wide end to tighten. Slide the front knot up to the base of your collar to fasten the tie. +
    • To create a dimple just below the front knot, squeeze the sides of the knot gently as you tighten.
    +
    +
    +
    +
  18. +
    +
    Advertisement
    + +
+
+
+
+ +
+
+
Method 4 +
+
+
+
Method 4 of 4:
+

Tying a Half Windsor Knot (Formal) +

+
+ + + PDF download + Download Article + + +
+
+
    +
  1. + +
    + Place the tie around your neck and let the sides hang in front of you. The wide end should be on the right side of your body, and hang roughly 12 inches (30 cm) lower than the narrow end on the left. +
    • The Half Windsor is a triangular, symmetrical knot suitable for formal occasions. Larger than the Four-in-hand but less bulky than the Windsor, this can work with most neckties and collar types.[9] + Neckties made from thicker fabric will likely require a spread or wide spread collar with this knot.
    +
    +
    +
    +
  2. +
  3. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Bring the wide end of the tie over to your left side, crossing over the narrow end. +
    +
    +
    +
  4. +
  5. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Complete a loop around the narrow end and pull the wide end back to the right side. +
    • The underside of the wide end should be visible at this point.
    +
    +
    +
    +
  6. +
  7. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Raise the wide end up to the loop of necktie at your collar. Keep it on the right side. +
    +
    +
    +
  8. +
  9. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Insert the wide tip down through the loop and pull it through from the left side, so it crosses under the narrow end. +
    +
    +
    +
  10. +
  11. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Bring the wide end back across the front and onto your right side. +
    +
    +
    +
  12. +
  13. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Fold the wide end up through the neck loop a second time. +
    +
    +
    +
  14. +
  15. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Loosen the front knot with your finger and insert the wide end. Pull it through to rest over the narrow end. +
    +
    +
    +
  16. +
  17. +
    +
    +
    +
    Watermark wikiHow to Tie a Tie
    +
    +
    + Gently squeeze the front knot as you pull to slide the knot up and create a dimple at the front of your tie. +
    +
    +
    +
  18. +
    +
    Advertisement
    + +
+


+

+
+
+
+ +
+
+
+
+

+ + Community Q&A + +

+
+
+
+
+
+
Search
+ +
+ Add New Question +
    +
  • +
    + +
    +
    Question
    +
    Can I use a scarf as a tie?
    + + + +
    +
    + + +
    + + +
    + + +
    + + + Community Answer + +
    + +
    + +
    + +
    Community Answer
    + +
    +
    + +
    + Yes, you can use a scarf as a tie. +
    + +
    +
    +
  • +
  • +
    + +
    +
    Question
    +
    What type of knot should I use for school?
    + + + +
    +
    + + +
    + + +
    + + +
    + + + Community Answer + +
    + +
    + +
    + +
    Community Answer
    + +
    +
    + +
    + The four-in-hand knot should work fine for school. +
    + +
    +
    +
  • +
  • +
    + +
    +
    Question
    +
    What is the quickest way to tie a tie?
    + + + +
    +
    + + +
    + + +
    + + +
    + + + Abhimanyu Sinha + +
    + +
    + +
    Abhimanyu Sinha
    + +
    Community Answer
    + +
    +
    + +
    + The four-in-hand knot should work. Doesn't take more than a minutes with practice. +
    + +
    +
    +
  • +
+ + See more answers +
+
+
+ + + +
Ask a Question
+
+ +
200 characters left
+ +
Include your email address to get a message when this question is answered.
+ Submit +
+ + +
+
+
    +
+
+
+
+
+
    +
+
+
+ + + + + + + + + + + + + + + + + +
+
+
+
Advertisement
+ +
+ + + +
+
+
+

+
+Video +

+Read Video Transcript +
+
+
+
+ +
+
+
+
+
+
+
+ + + +
+
+
+
+

+
+Tips +

+
+
+
    +
  • +
    Ideally, the tip of the tie should graze the top of your belt buckle. It's all right if the tie dips down to the bottom of the belt buckle ("Italian style"). If it's any lower, try a knot that uses plenty of cloth (such as the Windsor), or switch to a shorter tie.[10] + Similarly, if the tie ends above your belt, buy a longer tie or try the Pratt knot, which doesn't use much cloth in the knot.
    +
    + + + +
  • +
  • +
    If you're helping someone tie their tie, tie it on yourself first since it will be easier to make the proportions accurate. Then, before you tighten the knot, transfer the tie to their neck.[11] + +
    +
    + + + +
  • +
  • +
    If your tie has a loop underneath the wide side of the tie, you may slide the narrow side through that loop to prevent it from "peeking" from behind the wide side of the tie.
    +
    + + + +
  • + + + + + +
+Show More Tips
+ +
+
Submit a Tip +
All tip submissions are carefully reviewed before being published
+
+ +
+ Name +
Please provide your name and last initial
+
+ +
+ + + Submit + +
+
+ +
+ Thanks for submitting a tip for review! +
+
+
+
+
+
+ +
+
+
Advertisement
+ +
+
+ +
+
+ + +
+
+ + + + + + + +
+
+
+
+
+ +
+

You Might Also Like

+
+
+Tie a Tie Half WindsorTie a Tie Half Windsor +
+
+Tie a Tie on Someone ElseTie a Tie on Someone Else +
+
+
+Tie a Windsor Knot Tie a Full Windsor Tie: 8 Easy Steps +
+
+Types of Tie Knots25 Classic & Trendy Tie Knots & How to Tie Them (Easy Steps) +
+
+Tie a Skinny Tie +
+
+Four in Hand Knot Tie a Four-in-Hand Knot Necktie (Step-by-Step) +
+
+Tie a DimpleTie a Dimple +
+
+Tie a Rose Bud Tie KnotTie a Rose Bud Tie Knot +
+
+Tie a Bow TieThe Easy Way to Tie a Perfect Bow Tie +
+
+Tie a Trinity KnotTie a Trinity Knot +
+
+Eldredge Knot Tie & Style the Eldredge Tie Knot +
+
+Novotny KnotNovotny Tie Knot: What It Is & How to Style It +
+
+Tie a Belt on a Trench Coat Tie a Coat Belt +
+
+Ideal Tie LengthWhat’s the Proper Tie Length? Look Refined in a Tie +
+
+
+
+
+
Advertisement
+ +
+
+

+
+References +

+ +
+ +
    +
  1. +↑ https://www.morgan.edu/Documents/ADMINISTRATION/CENTERS/ccd/Handouts/Handout~How%20to%20Tie%20a%20Tie.pdf +
  2. +
  3. +↑ Chloée Ohayon-Crosby. Costume Designer & Wardrobe Specialist. Expert Interview +
  4. +
+
+ +
+
+

About This Article

+
+
+ +
+ +
+
+ +
+ +
Chloée Ohayon-Crosby
+ + + + +
+
+
+ Co-authored by: +
+ +
Costume Designer & Wardrobe Specialist
+
+
+ +
+
+ This article was co-authored by Chloée Ohayon-Crosby. Chloée Ohayon-Crosby is a Costume Designer and Wardrobe Specialist in Los Angeles, California. With over eight years of experience in fashion consulting, Chloée specializes in personal, film, theater, and commercial styling as well as image consulting and costume design. Chloée has worked as an assistant designer for the distinguished fashion house Chloée and as a freelance stylist with Glamour Italia. Chloée studied Fine/Studio Arts at the Ecole Nationale Supérieure des Beaux-Arts and Fashion Design and Merchandising at the world renowned ESMOD École Supérieure des Arts in Paris, France. This article has been viewed 7,154,301 times. +
+ + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
355 votes - 85%
+
+
+ + +
+ +
+
+ Co-authors: 240 +
+
+ Updated: May 1, 2026 +
+
+ Views: 7,154,301 +
+
+ + +
+ Categories: Featured Articles | Ties | Knot Tying +
+ +
+
+ +
+
+Article SummaryX

The best way to tie a tie for beginners is the 4-in-hand knot. + +Step 1. Button the top button of your shirt, and fold your collar up. +Step 2. Hang the tie around your collar so that the wide end is on your right side, about 4 inches below the narrow end. +Step 3. Cross the wide end in front of the narrow end. +Step 4. Bring the wide end behind the narrow end, and pull the wide end from left to right. Hold the narrow end steady throughout. +Step 5. Cross the wide end in front of the narrow end from right to left. +Step 6. Pull the wide end up through the neck loop, then push the wide end down through the loop you created in front. +Step 7. Hold the narrow end in one hand, then pull the wide end to tighten the knot. Straighten the knot as needed. +Step 8. Check to make sure that the end of the tie is about at the middle of your belt buckle, and tuck the narrow end of the tie into the loop on the back side of the wide end. +Step 9. Fold your collar down, and make sure that the tie is covered by the collar all the way around your neck.

+Did this summary help you?
+ +
+

+
+ + + + +
Thanks to all authors for creating a page that has been read 7,154,301 times.
+
+
+
+
+ +
+
+

Reader Success Stories

+
+
+ +
+ +
    +
  • + +
    + + + + + + Daddy P. + + +
    +

    Daddy P.

    +

    May 9

    +
    +
    + +
    + "I got my first ties from goodwill and this helped me figure out how to tie a tie!!" +
    + + + +
  • + +
+ + + + Share your story + +
+
+
+
+ +
+

Did this article help you?

+
+ + +
+
+
+
+ +
+
+
+
Advertisement
+ +
+


+
+ + + + + + + + + + + + +
+ X +
+
+

+

+
+
+ +
+
+
+ +
-
-
+ + + + + \ No newline at end of file diff --git a/tests/test_pywikihow.py b/tests/test_pywikihow.py new file mode 100644 index 0000000..d7761a8 --- /dev/null +++ b/tests/test_pywikihow.py @@ -0,0 +1,202 @@ +import os + +import pytest + +import pywikihow +from pywikihow import HowTo, RandomHowTo, search_wikihow +from pywikihow.exceptions import ParseError, UnsupportedLanguage + +FIXTURES = os.path.join(os.path.dirname(__file__), "fixtures") + + +def _fixture(name): + with open(os.path.join(FIXTURES, name), "rb") as f: + return f.read() + + +TIE_A_TIE = _fixture("tie_a_tie.html") +FOLD_FITTED_SHEET = _fixture("fold_fitted_sheet.html") +CONTAR_CELULAS_PT = _fixture("contar_celulas_pt.html") +SEARCH_BITCOIN = _fixture("search_bitcoin.html") +NOT_FOUND = _fixture("not_found.html") + + +def _patch_get_html(monkeypatch, mapping): + """mapping: dict of substring -> fixture bytes, checked in order.""" + + def fake_get_html(url): + for substring, body in mapping.items(): + if substring in url: + return body + raise AssertionError(f"unexpected URL fetched in test: {url}") + + monkeypatch.setattr(pywikihow, "get_html", fake_get_html) + + +class TestHowToHappyPath: + def test_parses_title_url_intro_and_steps(self, monkeypatch): + _patch_get_html(monkeypatch, {"Tie-a-Tie": TIE_A_TIE}) + how = HowTo("https://www.wikihow.com/Tie-a-Tie", lazy=False) + + assert how.title == "Tie a Tie" + assert how.url == "https://www.wikihow.com/Tie-a-Tie" + assert how.intro + assert how.n_steps == 36 + assert how.steps[0].summary == "Drape the tie around your neck." + + def test_as_dict_roundtrip(self, monkeypatch): + _patch_get_html(monkeypatch, {"Tie-a-Tie": TIE_A_TIE}) + how = HowTo("https://www.wikihow.com/Tie-a-Tie", lazy=False) + d = how.as_dict() + + assert d["title"] == how.title + assert d["n_steps"] == how.n_steps + assert len(d["steps"]) == how.n_steps + assert d["steps"][0]["summary"] == how.steps[0].summary + + def test_lazy_parsing_defers_until_first_access(self, monkeypatch): + _patch_get_html(monkeypatch, {"Tie-a-Tie": TIE_A_TIE}) + how = HowTo("https://www.wikihow.com/Tie-a-Tie") + assert how._parsed is False + assert how.title == "Tie a Tie" + assert how._parsed is True + + +class TestPictureBug: + """Regression tests for the step-picture correlation bug. + + wikiHow no longer nests step images inside their `div.step`, and no + longer uses a `data-src` attribute for the final image URL. The old + code assumed both, so `HowToStep.picture` was always empty and, on + pages with more images than steps, `_parse_pictures` could raise an + uncaught IndexError (masked as a generic ParseError). + """ + + def test_pictures_are_populated_from_src(self, monkeypatch): + _patch_get_html(monkeypatch, {"Tie-a-Tie": TIE_A_TIE}) + how = HowTo("https://www.wikihow.com/Tie-a-Tie", lazy=False) + + pictured = [s for s in how.steps if s.picture] + assert pictured, "no step picture was populated" + for step in pictured: + assert step.picture.startswith("http") + + def test_pictures_correlate_to_the_right_step(self, monkeypatch): + _patch_get_html(monkeypatch, {"Tie-a-Tie": TIE_A_TIE}) + how = HowTo("https://www.wikihow.com/Tie-a-Tie", lazy=False) + + # Step-1 image must land on the first step (index 0), not on + # whichever step happens to be next in image-list order. + step_1_pic = how.steps[0].picture + assert step_1_pic is not None + assert "Step-1-" in step_1_pic + + def test_multi_part_page_does_not_raise_index_error(self, monkeypatch): + # This page has more links (12, including the + # summary image) than the article's step count, and images are + # spread unevenly across three "parts"/sections. Before the fix + # this raised IndexError -> masked as ParseError. + _patch_get_html( + monkeypatch, {"Fold-a-Fitted-Sheet": FOLD_FITTED_SHEET} + ) + how = HowTo("https://www.wikihow.com/Fold-a-Fitted-Sheet", lazy=False) + + assert how.n_steps == 11 + # first step of the article has a picture, correctly assigned + assert how.steps[0].picture is not None + assert "Step-1-" in how.steps[0].picture + # the summary/intro image (no "Step-N" token) must never bleed + # into a step's picture + assert all( + step.picture is None or "Summary" not in step.picture + for step in how.steps + ) + + +class TestTitleUnicodeBug: + """Regression test: non-ASCII titles must be percent-decoded.""" + + def test_title_is_url_decoded(self, monkeypatch): + _patch_get_html( + monkeypatch, {"Contar-C%C3%A9lulas": CONTAR_CELULAS_PT} + ) + how = HowTo( + "https://pt.wikihow.com/Contar-C%C3%A9lulas-no-Google-" + "Planilhas-no-Windows-ou-Mac", + lazy=False, + ) + assert "%" not in how.title + assert "Células" in how.title + + +class TestSearch: + def test_search_yields_howto_objects(self, monkeypatch): + _patch_get_html( + monkeypatch, + { + "wikiHowTo?search": SEARCH_BITCOIN, + "Tie-a-Tie": TIE_A_TIE, + }, + ) + # every result link resolves through the same stand-in fixture; + # this exercises pagination/max_results, not per-result content + monkeypatch.setattr( + HowTo, + "_parse", + lambda self: setattr(self, "_parsed", True) or setattr( + self, "_title", "stub" + ), + ) + results = search_wikihow("buy bitcoin", max_results=3) + assert len(results) == 3 + + def test_search_url_encodes_special_characters(self, monkeypatch): + captured = {} + + def fake_get_html(url): + captured["url"] = url + return SEARCH_BITCOIN + + monkeypatch.setattr(pywikihow, "get_html", fake_get_html) + monkeypatch.setattr( + HowTo, + "_parse", + lambda self: setattr(self, "_parsed", True) or setattr( + self, "_title", "stub" + ), + ) + search_wikihow("buy bitcoin & stocks", max_results=1) + assert "&" not in captured["url"].split("search=", 1)[1] + assert "%26" in captured["url"] or "+" not in captured["url"] + + def test_unsupported_language_raises(self): + with pytest.raises(UnsupportedLanguage): + search_wikihow("anything", lang="xx") + + def test_random_howto_unsupported_language_raises(self): + with pytest.raises(UnsupportedLanguage): + RandomHowTo(lang="xx") + + +class TestMalformedInput: + def test_missing_title_raises_parse_error(self, monkeypatch): + _patch_get_html(monkeypatch, {"ThisPageDoesNotExist": NOT_FOUND}) + how = HowTo( + "https://www.wikihow.com/Special:ThisPageDoesNotExist123456" + ) + with pytest.raises(ParseError): + how._parse() + + def test_parse_error_preserves_original_cause(self, monkeypatch): + # Regression test: `raise ParseError` used to discard the + # underlying exception, making failures unfixable to debug (this + # masked the IndexError picture bug above as a bare ParseError). + _patch_get_html(monkeypatch, {"ThisPageDoesNotExist": NOT_FOUND}) + how = HowTo( + "https://www.wikihow.com/Special:ThisPageDoesNotExist123456" + ) + try: + how._parse() + pytest.fail("expected ParseError") + except ParseError as exc: + assert exc.__cause__ is not None