Skip to content

Commit ce108ae

Browse files
authored
Update readme.md
1 parent 1bcedad commit ce108ae

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

readme.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,23 @@ for key, value in prices.items():
9494

9595
### Misplaced, missing, or mismatched punctuation
9696

97-
1. Ensure that parentheses `()`, brackets `[]`, and braces `{}` are properly closed. When left unclosed, the Python interpreter treats everything following the first parenthesis, bracket, or brace as a single statement. Take a look at this web scraping code sample that sends a set of [<u>crawling</u>](https://oxylabs.io/blog/crawling-vs-scraping) instructions to our [<u>Web Crawler tool</u>](https://oxylabs.io/features/web-crawler):
97+
1. Ensure that parentheses `()`, brackets `[]`, and braces `{}` are properly closed. When left unclosed, the Python interpreter treats everything following the first parenthesis, bracket, or brace as a single statement. Take a look at this web scraping code sample that sends parsing instructions to our [web scraping tool](https://oxylabs.io/products/scraper-api/web):
9898

9999
```python
100100
payload = {
101-
"url": "https://www.example.com/",
102-
"filters": {
103-
"crawl": [".*"],
104-
"process": [".*"],
105-
"max_depth": 1,
106-
"scrape_params": {
107-
"user_agent_type": "desktop",
108-
},
109-
"output": {
110-
"type_": "sitemap"
101+
"source": "universal",
102+
"url": "https://sandbox.oxylabs.io/products/1",
103+
"parse": True,
104+
"parsing_instructions": {
105+
"title": {
106+
"_fns": [
107+
{
108+
"_fn": "css_one",
109+
"_args": ["h2"]
110+
}
111+
]
112+
}
111113
}
112-
}
113114

114115
# Error message
115116
File "<stdin>", line 1
@@ -118,27 +119,25 @@ payload = {
118119
SyntaxError: '{' was never closed
119120
```
120121

121-
At first glance, it looks like the payload was closed with braces, but
122-
the Python interpreter raises a syntax error that says otherwise. In
123-
this particular case, the `“filters”` parameter isn’t closed with
124-
braces, which the interpreter, unfortunately, doesn’t show in its
125-
traceback. You can fix the error by closing the `“filters”` parameter:
122+
At first glance, it may look like the `payload` was closed with braces, but the Python interpreter raises a syntax error that says otherwise. You can fix the error by closing the `payload`:
123+
126124

127125
```python
128126
payload = {
129-
"url": "https://www.amazon.com/",
130-
"filters": {
131-
"crawl": [".*"],
132-
"process": [".*"],
133-
"max_depth": 1
134-
}, # Add the missing brace
135-
"scrape_params": {
136-
"user_agent_type": "desktop",
137-
},
138-
"output": {
139-
"type_": "sitemap"
127+
"source": "universal",
128+
"url": "https://sandbox.oxylabs.io/products/1",
129+
"parse": True,
130+
"parsing_instructions": {
131+
"title": {
132+
"_fns": [
133+
{
134+
"_fn": "css_one",
135+
"_args": ["h2"]
136+
}
137+
]
138+
}
140139
}
141-
}
140+
} # Add the missing brace
142141
```
143142

144143
2. Make sure you close a string with proper quotes. For example, if you started your string with a single quote ‘, then use a single quote again at the end of your string. The below code snippet illustrates this:

0 commit comments

Comments
 (0)