You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+28-29Lines changed: 28 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -94,22 +94,23 @@ for key, value in prices.items():
94
94
95
95
###Misplaced, missing, or mismatched punctuation
96
96
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 sendsa 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 sendsparsinginstructions to our[web scraping tool](https://oxylabs.io/products/scraper-api/web):
98
98
99
99
```python
100
100
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
+
}
111
113
}
112
-
}
113
114
114
115
# Error message
115
116
File"<stdin>", line1
@@ -118,27 +119,25 @@ payload = {
118
119
SyntaxError:'{' was never closed
119
120
```
120
121
121
-
At first glance, it looks like the payload was closedwith braces, but
122
-
the Python interpreter raises a syntax error that says otherwise. In
123
-
this particular case, the`“filters”` parameter isn’t closedwith
124
-
braces, which the interpreter, unfortunately, doesn’t showin its
125
-
traceback. You can fix the error by closing the`“filters”` parameter:
122
+
At first glance, it may look like the`payload` was closedwith braces, but the Python interpreter raises a syntax error that says otherwise. You can fix the error by closing the`payload`:
123
+
126
124
127
125
```python
128
126
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
+
}
140
139
}
141
-
}
140
+
}# Add the missing brace
142
141
```
143
142
144
143
2. Make sure you close a stringwith proper quotes. For example,if you started your stringwith a single quote ‘, then use a single quote again at the end of your string. The below code snippet illustrates this: