Category Archives: Error

Python scrapy/ ERROR: Spider must return request, item, or None, got ‘Tag ‘insettlement program

When I write about a crawler today, I encounter a pit and prompt [scratch. Core. Scraper] error: spider must return request, item, or none, got ‘tag’ in & lt; GET https://www.

In fact, the reason is very unexpected. I use item in the code, and at the same time, the scratch uses item to pass data. As a result, this problem is caused

 for item in soup.select(".job-list-item"):
            uu=item.select_one("a").get('href').split("?")[0]
            if uu is not None:
                item['wz']=uu
                yield item

If you change yield to return, no error will be reported, but the data cannot be transferred. You need to change it to the following code

for itema in soup.select(".job-list-item"):
            uu=itema.select_one("a").get('href').split("?")[0]
            if uu is not None:
                item['wz']=uu
                yield item

 

[AWS] Solve Error: Uploaded file must be a non-empty zip

 
If you got the following error when run the sam deploy :
 

CREATE_FAILED AWS::Lambda::Function <YourFunctionName> Resource handler
Function returned message:
"Uploaded file must be
a non-empty zip
(Service: Lambda,
Status Code: 400,
Request ID: <YourRequestID>, Extended Request
ID: null)"
(RequestToken: <YourRequestToken>,
HandlerErrorCode:
InvalidRequest)

 
First of all, check your lambda function resource path in the template.yaml file, make sure you have the correct path, and it did have the specified source code file under the folder.
 
Otherwise, it might be the node version issue, the CDK bug is #12536 and the upstream NodeJS bug is #37027. 
Try to change the node version to older than v15.5.0 to mitigate this issue:
 

nvm list
nvm use <Older Version>

 

ASP.NET Core – Handle Error on Razor Page

preface

The website should not have error, but it will happen, so it is very important to give users a friendly error page

 

Main reference

Handle errors in ASP.NET Core

 

Error handling during development

In dev, asp.net core has made an error page for us, which is very friendly to developers  

We don’t need to make any settings

 

 

Error handling during production

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/InternalServerError");
}

Useexceptionhandler will find the corresponding razor page rendering return content through path/internalservererror

In the model, we can get relevant exception information through request features

public void OnGet()
{
    var exceptionHandlerPathFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
    RequestId = Activity.Current?.Id ??HttpContext.TraceIdentifier;
}

 

404 page

404 is not an exception, so the above scheme will not process 404

app.UseStatusCodePagesWithReExecute("/Status/{0}");

The 404 problem can be solved through usestatuscodepageswithreexecute. Its execution is similar to that of exception handler

Find the page according to the path and render it back. Similarly, you can get the status information in the model

public void OnGet(string statusCode)
{
    var exceptionHandlerPathFeature = HttpContext.Features.Get<IStatusCodeReExecuteFeature>();
    RequestId = Activity.Current?.Id ??HttpContext.TraceIdentifier;
}

 

Two solutions to cross origin read blocking (CORB) blocked cross origin response error of Web Service API

Two solutions to cross origin read blocking (CORB) blocked cross origin response error reporting of Baidu Web Service API

1. JQuery mode

        $(function () {
      //Note that at the end add &callback = callback
            var url = "http://api.map.baidu.com/place/v2/search?query=ATM机&tag=银行&region=北京&output=json&ak=F552bedbee2ec8fa6bae7b7a08201&callback=callback";

            $.ajax({
                type: "get",
                async: false,
                url: url,
                dataType: "jsonp",
                jsonp: "callback", //Callback function name (right) of the parameter name (left), default callback, the server side through which to get back to the name of the callback function
                jsonpCallback: "callback", //default jquery auto-generated, the name of the callback function returned callback
                success: function (data) {
                    var json = JSON.stringify(data);
                    console.log(json);
                },
                error: function (err) {
                    console.log(err);
                }
            });
        });

2. Client mode

        // Provide url address for jsonp service;
        var url = "http://api.map.baidu.com/place/v2/search?query=ATM机&tag=bank&region=Beijing&output=json&ak= F552bedbee2ec8fa6bae7b7a08201&callback=callback";
        // Create script tag and set its properties;
        var script = document.createElement("script");
        script.setAttribute("src", url);
        document.getElementsByTagName("head")[0].appendChild(script);

        // The callback function after getting the query result;
        var callback = function (data) {
            var json = JSON.stringify(data);
            console.log(json);
        };

Done!

Git fetch upstream Error: XXX Permission denied (publickey). fatal: Could not read from remote repository

This error is usually your key error and needs to be regenerated.

Open bash in any path of windows, and then enter the command SSH keygen – t RSA – C email address
the default generated key is/C/users/user name/.SSH

View public key

Copy the public key to GitHub
enter the warehouse and click setting -> Deploy Keys -> Add new, paste the public key, enter the key input box, check allow push, and finally click the add key button to submit.

[Solved] Docker rmi Error: Error response from daemon: conflict: unable to delete 6c20ffa54f86 (must be forced) – image is being used by stopped container 6e81c0d9b6ab

Docker RMI deletes the image

Step 1:

If there are relevant containers   The container must be deleted first

Step 2:

After making a custom image, docker images will find that the image name is different, but the image ID is the same. Docker cannot recognize it and cannot delete it.

Docker RMI “image name” is required for deletion   Instead of ‘mirror ID’.

C Language Error: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token

I haven’t used C for a long time. When I brush questions with C, I encounter this error.. I’ve been looking for punctuation errors… Finally, I found that it was caused by initializing data in the structure!

Note: variables in C structure must not be initialized! Assign values like lines 10 and 11.

C + + can be initialized when declared in a class after the C + + 11 standard.

[Solved] insertSale attempted to return null from a method with a primitive return type (int).

1. Problems arising

I am executing the mytest program. Yes, I reported an error.

1. Dao layer interface

1     int insertSale(Sale sale);

2. Service layer

1     @Override
2     public void buy(Integer goodsId, Integer nums) {
3 
4         // Record sales information and add records to the sale table
5         ....
6         saleDao.insertSale(sale);
7      }

The above error will be reported after running the program

2. Error reason

The reason for this error is that the service layer buy() method does not return a value. And we defined the dao layer method is to return int, there will be the following prompt

3. Solution

This is a problem with the Dao layer. The Dao layer is modified as follows:

1     void insertSale(Sale sale);

Expected indentation of 8 spaces but found [How to Solve]

The error “expected indentation of 8 spaces but found…” is reported by Vue eslint of vscade development

Solution: modify the eslint configuration file.Eslintrc.JS

.eslintrc.js

// https://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module',
  },
  env: {
    browser: true,
    node: true,
    es6: true,
  },
  extends: 'eslint:recommended',
  // required to lint *.vue files
  plugins: ['vue'],
  globals: {
    document: true,
    window: true,
  },
  // add your custom rules here
  rules: {
    //0--Not enabled; 1 - a warning will be given if there is a problem; 2 - an error will be reported if there is a problem
    indent: [
      2,
      2,
      {
        SwitchCase: 1, // (default: 0) specifies the indentation level of the switch-case statement
      },
    ], // force consistent indentation
    eqeqeq: [2, 'always'], // Require the use of === and ! ==
    semi: [2, 'never'], // require or disallow the use of semicolons instead of ASI
    quotes: [2, 'single'], // force the use of consistent backticks, double or single quotes
    'no-console': 'off',
    camelcase: 2, // force camelcase naming
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ?'error' : 'off',
  },
}

CocoaPods could not find compatible versions for pod [How to Solve]

The solution is to run :
pod repo update –verbose
Then execute the command:
pod install
If there is still an error, delete the podfile.lock file
If you still get an error, delete the third-party library version and run pod install again.

// The following is the problem of the error

superlee-MacBook-Pro ios_code_new_warehouse % pod install
Analyzing dependencies
[!] The version of CocoaPods used to generate the lockfile (1.11.0) is higher than the version of the current executable (1.10.1). Incompatibility issues may arise.
[!] CocoaPods could not find compatible versions for pod "JMLink":
In snapshot (Podfile.lock):
JMLink (= 1.2.4)

In Podfile:
JMLink (= 1.2.4)

None of your spec sources contain a spec satisfying the dependencies: `JMLink (= 1.2.4), JMLink (= 1.2.4)`.

You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
[email protected] ios_code_new_warehouse % pod install
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "JMLink":
In Podfile:
JMLink (= 1.2.4)

None of your spec sources contain a spec satisfying the dependency: `JMLink (= 1.2.4)`.

You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.